- This topic has 8 replies, 4 voices, and was last updated 4 years, 10 months ago by
Elvin.
-
AuthorPosts
-
May 11, 2021 at 7:37 am #1774490
Gerhard
Hello,
I have some trouble with my single post navigation!
.
My categories are years:
1992,1993,1994…
With the months as sub-categories:
Januar, Februar, März…
Take the following example for März 2010:
05.03.2010, 10.03.2010, 10.03.2010/2, 12.03.2010, 12.03.2010/2, 18.03.2010…
Now the previous-link of 10.03.2010 should point to 05.03.2010 and the next-link should go to 10.03.201/2.
The previous-link of 05.03.2010 should point to the next post chronologically that is 28.01.2010 because there are no posts in February.
Then the last post of lets say Dezember 2010 should have a next-link to the first post of Januar 2011 whereas the previos-link of the first post of Januar 2011 should go to the last post of Dezember 2010.
As you can see it’s rather tricky and I hope there is a solution and you can help me.Greetings from Cologne
GerhardMay 11, 2021 at 3:57 pm #1774996Elvin
StaffCustomer SupportHi there,
Can you try adding this filter? so the post stays within its category.
add_filter('generate_category_post_navigation','__return_true');Let us know how it goes.
May 14, 2021 at 5:49 am #1779945Gerhard
Hi Elvin,
after adding the filter now sometimes there is an order sometimes not. For example it jumps from post 10.03.2010/2 to 10.11.2010 instead of 12.03.2010?
May 15, 2021 at 9:27 am #1781914Tom
Lead DeveloperLead DeveloperHi there,
It seems like this would need some sort of solution that sorted posts by category and sub-category together as one sorting parameter.. I’m not sure this is how the default WordPress post navigation was developed. It may require a custom solution, unfortunately.
May 17, 2021 at 7:12 am #1784717Gerhard
Thank you Tom!
So I should perhaps better do the page without sub-categories (=months) but only with categories (= years)
Am I right thinking that WP would then sort my single posts(=german dates) correctly?
Greetings from Cologne
GerhardMay 17, 2021 at 7:21 am #1784735Alexander
Hi Gerhard,
can’t you simply adjust the date of the posts themselves, instead of using categories and tags? I’m asking because I do that all the time to create a chronologically correct archive. 🙂
Wordpress had date-based archives built-in, in other words you can use yoursite.something/2012/09/ to access the archive (even when your permalink structure is NOT using dates at all).
Grüsse aus San Diego 🙂
Alex.May 17, 2021 at 11:09 pm #1786748Elvin
StaffCustomer SupportGP uses the default way WordPress creates navigation links. It uses previous_post_link()
https://github.com/tomusborne/generatepress/blob/b60b853630da6d9015722da903e53c8064148b0a/inc/structure/post-meta.php#L58and next_post_link()
https://github.com/tomusborne/generatepress/blob/b60b853630da6d9015722da903e53c8064148b0a/inc/structure/post-meta.php#L66Now, the issue is, these core functions don’t take arguments to specify how it gets sorted.
This means we go higher up and do things with
get_adjacent_post()Check this:
May 22, 2021 at 5:34 am #1793605Gerhard
Hello,
I simply changed the single post’s saving date which is now my chronological date(=entry-title) and now have the prev/next links in the correct order.
I guess my thoughts were too complicated…
Thanks to the great team of GP for help anyway!!
Greetings from Cologne
GerhardMay 23, 2021 at 5:04 pm #1795317Elvin
StaffCustomer SupportNice one. Glad you got it sorted. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.