Advanced Custom Fields in List category posts excerpt
-
I’ve been having issue with this for the past two weeks.
Does anyone know how to to this ?
i found solution to show advanced custom fields excerpt in category posts view and on single post, but had no luck in showing it on list category posts excerpt.
this is the solution i found on with regards to displaying excerpt :
http://wordpress.org/support/topic/how-to-pull-excerpt-from-advanced-custom-field?replies=32
putting this in fuction.php :
function custom_field_excerpt() {
global $post;
$text = get_field(‘field_name’);
if ( ” != $text ) {
$text = strip_shortcodes( $text );
$text = apply_filters(‘the_content’, $text);
$text = str_replace(‘]]>’, ‘]]>’, $text);
$excerpt_length = 20; // 20 words
$excerpt_more = apply_filters(‘excerpt_more’, ‘ ‘ . ‘[…]’);
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
return apply_filters(‘the_excerpt’, $text);
}putting this inside loop.php
<?php echo custom_field_excerpt(); ?>if i put this under single blog post in loop it works, if i put this inside blog posts loop it doesnt show it.
Does anyone have solution for this ? am i putting this inside wrong file ?
- The topic ‘Advanced Custom Fields in List category posts excerpt’ is closed to new replies.