Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Query loop in search results

  • Hello,

    I am setting up a template for search results. For this I have created a query loop with generateblocks.

    The thing is, in order to show the blog posts that actually go with the user’s search, I have to activate the option “Inherit query from template”.

    And by doing so, the configuration of the number of blog posts per page is lost.

    Which I have set to 16, but by activating the option, only 10 are shown.

    Here is a video that explains it better:

    Can you help me to fix this?


  • Hi there,

    the inherit query will use the number of posts per page that you set in the Dashboard > Settings > Reading
    Do you want the search results to show a different amount to that?

    If so you can use the pre_get_posts filter to set the number of pages.
    Heres a PHP Snippet to do that:

    function custom_posts_per_page( $query ) {
        if ( !is_admin() && $query->is_main_query() && $query->is_search() ) {
            $query->set( 'posts_per_page', 16 ); // Set the number of posts per page for search page
    add_action( 'pre_get_posts', 'custom_posts_per_page' );
  • Hello David,

    The first option is very good, thanks!

    One more thing.

    I would like in the breadcrumbs and the h1 to dynamically display the search term.

    Something like: “You searched for: [TERM]”.

    I currently have the headline as a dynamic element displaying the title, the problem is that it is displaying it as the title of a blog post.

    Here is an image that shows it better:

    Could you help me with this please?


  • Hi there,

    We don’t have control over the breadcrumbs’ output, unfortunately.

    you will need to reach out to the plugin’s support for this.

  • Hello Ying,

    I have already solved the breadcrumbs.

    But, the headline element is from GenerateBlocks.

  • It looks like the title is what you want already:

    Let me know if I miss anything.

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