[Resolved] Need category single post next/prev navigation when category is sorted by title

Home Forums Support [Resolved] Need category single post next/prev navigation when category is sorted by title

Home Forums Support Need category single post next/prev navigation when category is sorted by title

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #502465
    Denise

    Hello GP Friends,

    I would like site visitors to have the ability to browse the individual posts by category, sorted by post title.

    Objectives:
    — All queries in the site are sorted by Post Title, ascending (and never by date)
    — All posts have just one category
    — When the user goes to a single post page, the navigation for previous/next posts stays within the category for that post. The previous/next will be sorted by Title

    QUESTION:
    How can I change the single post navigation to follow the post’s category loop, sorted by Title?

    I am currently using two code snippets.
    The first is to stay within the category.
    The second is to order queries by title.

    add_action( ‘after_setup_theme’, ‘mdp_category_specific_post_navigation’ );
    function mdp_category_specific_post_navigation() {
    add_filter( ‘generate_category_post_navigation’, ‘__return_true’ );
    }

    add_action( ‘pre_get_posts’, ‘mdp_modify_query_order’ );
    function mdp_modify_query_order( $query ) {
    $query->set( ‘orderby’, ‘title’ );
    $query->set( ‘order’, ‘ASC’ );
    }

    Many thanks,
    Denise

    (question updated and clarified on 2/22/2018 at 4:35 CST)

    #503357
    Tom
    Lead Developer
    Lead Developer

    This was a tough one! I think I found something that may help: https://wordpress.stackexchange.com/questions/73190/can-the-next-prev-post-links-be-ordered-by-menu-order-or-by-a-meta-key

    Let me know πŸ™‚

    #503619
    Denise

    Wow, thanks so much for this help, Tom. I’ll have some time to work on the site this weekend and let you know.

    As always, working with GeneratePress is such a delight. I look forward to this project a lot more since I switched to using your theme =)

    Best wishes,
    Denise

    #503907
    Tom
    Lead Developer
    Lead Developer

    No problem! I hope it helps! πŸ™‚

    #506519
    Denise

    Thanks, Tom. That’s what I was looking for. I’d rather not have to include an extra plugin so I’ll try and write the code myself, based on this one.

    You may close this ticket.

    Best wishes,
    Denise

    #507103
    Tom
    Lead Developer
    Lead Developer

    Glad I could help πŸ™‚

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