Support

Account

Home Forums ACF PRO problem with custom_field_excerpt Reply To: problem with custom_field_excerpt

  • Hi @inforesist

    I’m not sure which thread you are referring to, but could you please try this code?

    function custom_field_excerpt() {
        global $post;
        $text = get_field('wysiwyg_test', $post->ID);
        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);
    }

    Hope this helps.