Support

Account

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!