Site logo

Archived topic

Number of posts to be displayed on the blog page

13 replies · Started by Irfan on April 2, 2023

Viewing posts 1–14 of 14

Hi,

I have a dedicated blog section on my site. In order to customize the appearance of excerpts etc I have setup an element with
- type "Block - Content Template"
- Location : Blog and All Archives
and I am using a query loop on this element type
However on the blog page the query duplication/repeats itself many times like loop within a loop. The same blog listings are shown many times.
Having spent considerable time searching for the problem, I have found out that the duplication amount is the same number as provided in Settings > Reading > Blog Pages show at most ____ posts.
For example if I set the above number to 3 posts and in the elements section if I set the block propery "Posts per page" to 3, this is what shows on the blog page

Blog Page Title
Post 1 Title/Excerpt - Post 2 Title/Excerpt - Post 3 Title/Excerpt - Post 4 Title/Excerpt

Blog Page Title
Post 1 Title/Excerpt - Post 2 Title/Excerpt - Post 3 Title/Excerpt - Post 4 Title/Excerpt

Blog Page Title
Post 1 Title/Excerpt - Post 2 Title/Excerpt - Post 3 Title/Excerpt - Post 4 Title/Excerpt

If I set the number to 1 under Settings > Reading > Blog Pages show at most ____ posts. section all is fine and there's no repetition.
Is this supposed to be the right way or am I missing something ?
Thanks in advance
Irfan

Hi there,

the Content Template block element replaces the template that is used to display each post.

if you want rebuild the index / archives with the Query Loop then use the Loop Template instead.

Hi David,

Thanks I corrected my template. However once I changed the template the pagination links at the bottom of the posts disappeared, how can I restore them ?

Hi Fernando,

How dumb of me yes I added pagination from the toolbar and I have the pagination back
Thanks for the fast response!

You're welcome, Irfan!

Now I have the pagination but how can I change the label in the pagination ? For previous/next labels etc.
And the URL of the pages are not SEO friendly like "?query-a14f3a8e-page=3". How can I make it like /page/3

I have the "Post name" in permalink structure in the settings of WP

Hi Fernando,

Thanks for your patience.
When I check it I see that this setting was off. I turned it on and the slug is now /page/2 ...etc
However when I click to next page and the URL is /page/2 then I get "page not found" from Wordpress web page

And when I set the Query Loop to “Inherit Loop from template” how can I set number of posts per page and add custom parameters. Before this setting was off I was able to customize it.

Under this switch there is the following explanation: "Toggle to use the global query context that is set with the current template, such as an archive or search."

If I turn it on how can customize the "global query context" ? Under which menu item can I access it ? The template I used is "Pixel" from GeneratePress : https://gpsites.co/pixel/

If you use Inherit Loop from template that is all you can do. You can't add other parameters to the block as those would conflict.
Instead you change the main query:
For example the number of posts that are displayed can be changed in the Settings > Reading -> Blog pages show at most

What other changes are you wanting to make to this loop ?

I was thinking of excluding some categories but I can try to live without it.
However as I have stated in my previous post the 2nd page shows "page not found" for the URL ..../page/2
I would appreciate if you can point me in the right direction for this problem

Can you make sure that there are no parameters set on the Query Loop block and then re-enable the Inherit Query from Template

Then go to Dashboard > Settings > Permalinks and click save changes to regenerate the permalinks.

If you want to exclude categories or other changes let me know

Thanks a lot, it worked :)

Glad to hear that!

This archived topic is closed to new replies.