Site logo

[Resolved] next/previous post navigation

Home Forums Support [Resolved] next/previous post navigation

Home Forums Support next/previous post navigation

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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
    Gerhard

    #1774996
    Elvin
    Staff
    Customer Support

    Hi 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.

    #1779945
    Gerhard

    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?

    #1781914
    Tom
    Lead Developer
    Lead Developer

    Hi 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.

    #1784717
    Gerhard

    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
    Gerhard

    #1784735
    Alexander

    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.

    #1786748
    Elvin
    Staff
    Customer Support

    GP 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#L58

    and next_post_link()
    https://github.com/tomusborne/generatepress/blob/b60b853630da6d9015722da903e53c8064148b0a/inc/structure/post-meta.php#L66

    Now, 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:

    https://wordpress.stackexchange.com/questions/73190/can-the-next-prev-post-links-be-ordered-by-menu-order-or-by-a-meta-key

    #1793605
    Gerhard

    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
    Gerhard

    #1795317
    Elvin
    Staff
    Customer Support

    Nice one. Glad you got it sorted. 🙂

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