php - Adding ACF field to post meta -


i found code controlling posts need edit:

$img = ( $mode == 'top' ) ? get_the_post_thumbnail( null, 'large' ) : get_the_post_thumbnail( null, 'medium' );      $the_image = sprintf( '<span class="c_img">%s</span>', $img );      $thumb_link = sprintf( '<a class="%s" href="%s" rel="bookmark" title="%s %s" style="%s">%s</a>', $classes, get_permalink( $post ), __( 'link to', 'pagelines' ), the_title_attribute( array( 'echo' => false ) ), $style, $the_image );      $output = ( 'top' == $mode ) ? sprintf( '<div class="full_img fix">%s</div>', $thumb_link ) : $thumb_link;      return apply_filters( 'pagelines_thumb_markup', $output, $mode, $format );  } 

that outputs this:

<span class="c_img"><img src="example image"></span> 

i need insert custom acf (advanced custom field) inside span. acf field name parent_category this:

<span class="c_img"><i class="cat_tag">deep house</i><img src="example image"></span> 

so need injected in between there:

<i class="cat_tag"><?php the_field('parent_category'); ?></i> 

how can right?

below i've glued relevant parts. please note comments, tell change / add:

$img = ( $mode == 'top' ) ? get_the_post_thumbnail( null, 'large' ) : get_the_post_thumbnail( null, 'medium' );      // add line....(gets markup requested, , custom field value)     $custom_field = '<i class="cat_tag">' . the_field('parent_category') . '</i>';     // , modify line.... (inserts returned string)     $the_image = sprintf( '<span class="c_img">%s%s</span>', $custom_field, $img );      $thumb_link = sprintf( '<a class="%s" href="%s" rel="bookmark" title="%s %s" style="%s">%s</a>', $classes, get_permalink( $post ), __( 'link to', 'pagelines' ), the_title_attribute( array( 'echo' => false ) ), $style, $the_image );      $output = ( 'top' == $mode ) ? sprintf( '<div class="full_img fix">%s</div>', $custom_field, $thumb_link ) : $thumb_link;      return apply_filters( 'pagelines_thumb_markup', $output, $mode, $format ); 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -