Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function advanced_custom_field_excerpt() {
- global $post;
- // check if the flexible content field has rows of data
- if( have_rows('post_flexible_content') ):
- // loop through the rows of data
- while ( have_rows('post_flexible_content') ) : the_row();
- $text = get_sub_field('flexible_text_editor');
- if ( '' != $text ) {
- $text = strip_shortcodes( $text );
- $text = apply_filters('the_content', $text);
- $text = str_replace(']]>', ']]>', $text);
- $excerpt_length =30; // 30 words
- $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
- $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
- break;
- }
- endwhile;
- else :
- // no layouts found
- endif;
- return apply_filters('the_excerpt', $text);
- }
- add_shortcode("flexible-excerpt", "advanced_custom_field_excerpt");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement