- This topic has 13 replies, 3 voices, and was last updated 2 years, 5 months ago by
David.
-
AuthorPosts
-
April 2, 2023 at 8:13 am #2593265
Irfan
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 pageBlog Page Title
Post 1 Title/Excerpt – Post 2 Title/Excerpt – Post 3 Title/Excerpt – Post 4 Title/ExcerptBlog Page Title
Post 1 Title/Excerpt – Post 2 Title/Excerpt – Post 3 Title/Excerpt – Post 4 Title/ExcerptBlog Page Title
Post 1 Title/Excerpt – Post 2 Title/Excerpt – Post 3 Title/Excerpt – Post 4 Title/ExcerptIf 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
IrfanApril 2, 2023 at 8:29 am #2593292David
StaffCustomer SupportHi 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.
April 4, 2023 at 12:30 am #2595754Irfan
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 ?
April 4, 2023 at 12:42 am #2595764Fernando Customer Support
Hi Irfan,
Did you use a Loop Template? If yes, you can add pagination as instructed here: https://generatepress.com/forums/topic/query-loops-pagination-for-categories/#post-2414210
April 4, 2023 at 1:03 am #2595794Irfan
Hi Fernando,
How dumb of me yes I added pagination from the toolbar and I have the pagination back
Thanks for the fast response!April 4, 2023 at 1:14 am #2595809Fernando Customer Support
You’re welcome, Irfan!
April 4, 2023 at 1:17 am #2595818Irfan
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/3I have the “Post name” in permalink structure in the settings of WP
April 4, 2023 at 1:28 am #2595837Fernando Customer Support
To clarify, have you set the Query Loop to “Inherit Loop from template”? Reference: https://docs.generatepress.com/article/block-element-loop-template/
April 4, 2023 at 1:58 am #2595894Irfan
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 pageAnd 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/
April 4, 2023 at 4:18 am #2596106David
StaffCustomer SupportIf 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 theSettings > Reading -> Blog pages show at most
What other changes are you wanting to make to this loop ?
April 4, 2023 at 5:16 am #2596182Irfan
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 problemApril 4, 2023 at 7:25 am #2596373David
StaffCustomer SupportCan 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
April 4, 2023 at 8:36 am #2596608Irfan
Thanks a lot, it worked 🙂
April 5, 2023 at 3:35 am #2597690David
StaffCustomer SupportGlad to hear that!
-
AuthorPosts
- You must be logged in to reply to this topic.