Home › Forums › General Issues › Can't get Excerpts to work › Reply To: Can't get Excerpts to work
Hi Jarvis,
I have the same problem of the first post, I did the following:
I have pasted this code in functions.php:
function custom_field_excerpt() {
global $post;
$text = get_field(‘extracto’);
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);
}
extracto is the name of the field
and pasted this, in archive.php
echo custom_field_excerpt();
but it doesn’t work… the default post element doesn’t recognize this field as the excerpt, I don’t know what is wrong, the field itself must contain some special type or something? right now is a common text field.
Help please!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.