Site logo

Archived topic

Bug with Dynamic Content Excerpt in Bloc Content Template Element

9 replies · Started by KEVIN on September 4, 2021

Viewing posts 1–10 of 10

Hi guys,
I'm trying to custom my blog page so i've created a bloc Content Template Element, but each time I try to add a "Dynamic Content Excerpt" the page doesn't want to save, and it finally crash. After that it's just impossible to go back to the element to edit it. I tried 4 times ^^
Here is what i do :
https://www.loom.com/share/1e2cb0f4b5e1435e89a4258be126ede1

Edit : I've just seen why it breaks, it's because i've added a snippet in order for the excerpt to show when i used "WP Show Posts". I've removed the snippet but now i don't have any content excerpt neither in the WP Show Posts content or with the "Dynamic Content Excerpt"...

I don't know how to show those excerpt content ?

I precised that i don't use the Excerpt metabox in the editor. I just want like 20-30 words of the post content.

Hi there,

Not sure if I understand.

Can you link me to the page in question?

Thanks.

Hi Leo,

Thanks for your answer.
In fact the problem i had (which you can see with the loom video) was because I added the snippet :

function manual_auto_excerpt($text) {
    global $post;
    $raw_excerpt = $text;
    if ( '' == $text ) {
        $text = get_the_content('');
        $text = strip_shortcodes( $text );
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);
    }    
    $text = strip_tags($text);
    /*** Change the excerpt words length. If you like. ***/
    $excerpt_length = apply_filters('excerpt_length', 30);
     
    /*** Change the Excerpt ending. If you like. ***/
    $excerpt_end = ' <a href="'. get_permalink($post->ID) . '">' . '&raquo; Continue Reading.' . '</a>'; 
    $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end);
     
    $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); 
    return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); 
}
add_filter('get_the_excerpt', 'manual_auto_excerpt', 5);

In order for me to show an excerpt content of my post with “WP Show Posts” plugin.

When I deactivate this snippet, I don't have the problem of saving my post anymore BUT it's impossible for me to show an excerpt content with the “Dynamic Content Excerpt” AND in the “WP Show Posts”.

So the main problem is that it's impossible for me to show an excerpt content and I don't know why ^^

Hi there,

can you share a link to the site where i can see the WP Show Posts so i can understand why that snippet is required.

Yes of course, the website is not yet online but i've sent you in private a link available for 48h. The "WP Show Post" is under "NOS OFFRES"

Hmmm... this is a tricky one.
So the the Excerpt ( without the code ) is empty as WordPress ignores any post content inside a nested block eg. Group Block, Container Block etc. when it generates the excerpt. The only real solution for that is to use a Manual Excerpt in the post, or DON'T create posts inside a Container ( or Group Block ).

Is there any need for adding the Container Block to the post ?

Ok I understand. Indeed if I use Manual Excerpt it works (I didn't test if the number of characters works).
For the post in a Container Block, in fact I didn't do that, I've installed "Realtor" template.

I have a question about WP Show Posts but not sure it's the right place to ask. Is there a way to add Custom Post meta ?

Thank you David :)

You're welcome

This archived topic is closed to new replies.