[Resolved] Automatic excerpts and the manual “Read More” tags looping in harmony.

Home Forums Support [Resolved] Automatic excerpts and the manual “Read More” tags looping in harmony.

Home Forums Support Automatic excerpts and the manual “Read More” tags looping in harmony.

  • This topic has 16 replies, 5 voices, and was last updated 5 months ago by VR.
Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
  • #2337324


    Through GB support, I got a partial solution to my problem.

    I expose it all here to see if a “complete” solution is possible.


    I was using WP Show Post. Trying now to switch to Query Loop blocks….

    We have SOME posts with the “more” tag included manually, and some not.

    With “WP Show Post”, when you tell it to show the automatic “excerpt” (x number of characters), it follows two steps:

    1st) if the post has a manually included “read more”, it gives priority to the “read more” (it uses the manually chosen intro text) and also shows the word formatting (bold, links, paragraph breaks, etc.).
    2nd) if the post does not have a read more, then it automatically generates the extract with x number of characters.

    But with Query Loop we only get the automatic “extract” with the given number of characters, and the text is not formatted.

    How to do with Query Loop what WP Show Post does?


    1. Add a “Headline Block”, and in “Dynamic options” choose “Excerpt”.

    2. Add this PHP code, so when it detects the “more” tag, the “GB headline block” will output the content instead.

    add_filter( 'generateblocks_dynamic_content_output', function( $output, $attributes ) {
        if ( 'post-excerpt' === $attributes['dynamicContentType'] ) {
            global $post;
            if ( strpos( $post->post_content, '<!--more-->' ) ) {
                $output = get_the_content();
        return $output;
    }, 10, 2 );


    The code works quite well, but… when a post has the tag “more”, the “read more” button appears twice (the one created in the querry loop and the automatic one of the post itself) (see photo and link)


    any solutions for a lover of the “more” tag?


    PD: A personal reflection on the margin of the problem: in your wonderful plugins and template (and I think in wordpress in general), I get the feeling that the “excerpt” is used more and more, and few (or no) options are given to control the posts with the “more” tag. If there was at least the option to show the excepts “with formatting” (bold, line breaks, etc.), we would use them more… but nothing like being able to control what is shown using the “more” tag πŸ˜‰

    Customer Support

    Hello there,

    Thanks for the input. We appreciate it.

    How about hiding the more tag button through CSS? Try adding this in Customize > Additional CSS:

    p.read-more-container {
        display: none;

    Does this work?


    Thanks, but in that case if someone accesses a category view, the “read more” button does not appear.

    Customer Support

    Hi there,

    you can target the just the query loop wrapper like so:

    .gb-query-loop-wrapper p.read-more-container {
        display: none;

    Does that work ?


    Thank you. It works! But just a small “critique”:

    GB + css code + a code snippet… to get something that “WP Show Post” already does ?!

    If possible, put more (or some) integration of the “more” tag together with the “automatic Excerpt” options in your roadmap πŸ˜‰

    Customer Support

    We’ll take a look at whats possible, i believe there are some limitations as to what we can do within the editor, so previews may not be exact. But ill add it to our Git issues πŸ™‚


    Thank you very much for listening to me.
    Thank you very much for taking it into account.
    Thank you very much for being the best support service I know.
    If I can help in any way, at tester level or whatever, count on me.

    Customer Support

    We try πŸ™‚
    I opened a Git Issue here – feel free to comment or track its progress:



    Thanks for the above code to output Dynamic Content when the <!–more–> tag is used. Super helpful!

    My question – is there any further code we can add to change the “Read More” button to text instead, or simply remove the button altogether? Like in this screenshot:


    We can use CSS to try and change the button back to text only, but that would be messier and risks the chance that the button would flash quickly before the CSS finished loading and it was then changed to text.


    Customer Support

    Hi Vico,

    You’ll still need to use the custom CSS provided above by David to hide the Read More link/button. If it isn’t working, can you provide the link to the site in question?


    Ok, thanks. Understood. We’ll use the default “Read More” button to simplify things then.

    Customer Support

    You’re welcome VR!


    Hello – We’re back.

    Two more questions:

    1) Is there a way to adapt the code above (post #2337324) to also work for the default Search Results post excerpts? They don’t use the “GB Headline block” so the code doesn’t work for them.

    Know we can create a whole new Search Results template, per https://generatepress.com/forums/topic/design-search-page/, but since the only change we need is displaying dynamic excerpts when the <!–more–> link exists in the post content, would rather not have to create a whole new template to achieve that.

    2) For static WP Pages – Is it possible to add a snippet to also include an auto-generated excerpt on the Search Results page? Or, will the client need to add a manual custom excerpt if they want text to appear for Pages, too?


    Customer Support

    1. For reference, can you re-share the link to the site in question?
    2. They should be included by default. We’ll check your search page first once you’ve shared the link.


    Thanks. Because this is a reply to the original support thread created by another use, I don’t see an option to include the URL privately.

    Instead, if you check the private link we provided on the below thread – it should have the site URL.

    – Post ID 2355797: https://generatepress.com/forums/topic/category-terms-display-issue-in-query-loop-gp-block/

    To see the Search Results page, just append “/?s=meetings#” to the end of the main URL. You’ll see the 2nd item, the “About” page, does not display any excerpt content even though there is content on the page itself.


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