Site logo

[Support request] Dynamic Blocks – With Excerpt

Home Forums Support [Support request] Dynamic Blocks – With Excerpt

Home Forums Support Dynamic Blocks – With Excerpt

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1711487
    Vijay

    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

    How do I add Dynamic Excerpt

    And can we similarly display page or custom post type excerpts?

    #1711711
    David
    Staff
    Customer Support

    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.

    #1931949
    Brenden

    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.

    #1932106
    Elvin
    Staff
    Customer Support

    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. 😀

    #1932512
    Brenden

    Both of your solutions are super helpful. I like using a container block and add styling to that. Thank you!

    #1933244
    Elvin
    Staff
    Customer Support

    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. 😀

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.