-
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…
-
Fernando
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…
-
Fernando
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…
-
Fernando
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!
-
Fernando
You’re welcome!
- You must be logged in to reply to this topic.