Hi, is it possible to create an excerpt from a CPT text area?
I want to show the last 3 reviews I made with a CPT and ACF on my frontpage.
But only an excerpt of 30 words of a text area ACF. and a read more button, to go to the complete review
With the Wordpress posts it is easily to create that. Is this posible with ACF?
I found some PHP code:
// Custom Excerpt function for Advanced Custom Fields
function custom_field_excerpt() {
global $post;
$text = get_field('position'); //Replace 'your_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);
}
But I don’t know how to show this in my query template (if it even works)