Archived topic
Dynamic Blocks - With Excerpt
5 replies · Started by Vijay on March 26, 2021
Hi Tom and Team,
Lovin the GP Theme Builder!
You made it so easy to use!
I notice its is so easy to display dynamic titles, categories, tags and event comment counts! Awesome!!!
How do I display the post excerpt? I tried, but can't seem to find the right term or option

And can we similarly display page or custom post type excerpts?
Hi there,
there are 2 GP specific blocks added to the editor - you want the Dynamic Content block it allows you to display the full Content or the Excerpt.
The block also applies to and post type that supports the excerpt.
The Dynamic Content block does work, but it is so limited compared to the GB Headline block. The Dynamic Content block does not have any styling/spacing options at all. It would be great if it was possible to pull in the post excerpt into the Headline block.
Hi Brenden,
You have a point.
But for now, if you want a workaround, we can make a dynamic headline block display excerpt.
Here's what you can do:
- create a Headline block and add dynamic-excerpt to its HTML anchor field.
- set the Headline Block's dynamic value to "post meta" and add the_excerpt to the meta field name.
You then add this PHP snippet.
add_filter('generate_dynamic_element_text', function($custom_field, $block){
if($block['attrs']['anchor'] = 'dynamic-excerpt'){
if ( ! empty( $block['attrs']['gpDynamicTextCustomField'] ) && $block['attrs']['gpDynamicTextCustomField'] == 'the_excerpt' ){
if (has_excerpt()) {
$excerpt = wp_strip_all_tags(get_the_excerpt());
$custom_field = $excerpt;
}
}
return $custom_field;
}
},20, 2);
But I think you can just wrap the dynamic content block w/ a container block and do your styling from there. :) Headline blocks are meant for headings. :D
Both of your solutions are super helpful. I like using a container block and add styling to that. Thank you!
Both of your solutions are super helpful. I like using a container block and add styling to that. Thank you!
Yeah that's the most ideal way of doing it.
No problem. Glad to be of any help. :D