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 WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

I can’t set up the post / page on the Query Loop block

  • Hi,

    I’m having a lot of trouble to set up the number of posts/page.

    On my home page, I have set up a Query Loop but without inheriting its content and I’ve set the number of post/page to 3.

    But the module renders out 5 elements on front (but it’s ok in the block editor).

    On my blog page, I have set up a Query Loop with inhering so there’s no option to set up the number of posts/page which is very weird.

    I tried to force this via my child theme, using the pre_get_posts method but it didn’t work either…

  • Hello there,

    Do you have sticky posts? If so, you’ll need to exclude them in the parameters of your Query Loop.

  • Thanks for your answer but that’s a very weird behavior also.

    For the front page I actually want to see only the sticky posts.

    And on the blog section, there’s no option to exclude categories since I use inherit…

  • That’s WordPress behavior.

    Try adding this snippet:

    function disablesticky($query) {
    
      if ($query->is_main_query() && ! is_admin() && $query->is_home() ) {
        $query->set( 'ignore_sticky_posts', true );
      }
    }
    add_action('pre_get_posts', 'disablesticky');

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

  • Thanks, there’s actually an option in the query loop block that allows me to display only sticky, so that works for me.

    But how about setting the posts/page in the blog module? Since it’s set up to ‘inherit’, the module gives no option to limit posts/page…

  • You’ll need to alter it in Settings > Reading. That’s the default WordPress control for that.

  • Got it thanks. Would be nice to still have a setting that would add some custom limits though.

    Have a nice day!

  • You’re welcome!

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