[Resolved] How to restrict Next & Previous post links to category?

Home Forums Support [Resolved] How to restrict Next & Previous post links to category?

Home Forums Support How to restrict Next & Previous post links to category?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #178923
    karl

    Hi,

    In the posts at the bottom there are links to the next post and previous post. If the next post is in a different category from the current one, how do you get it to stop the next/previous link from showing?

    I have tried putting this in the under content section in hook:

    <?php previous_post_link(‘<h6 style=”float:left;”>%link</h6>’, ‘Previous’, TRUE); ?>
    <?php next_post_link( ‘<h6 style=”float:right;”>%link</h6>’, ‘Next’, TRUE ); ?>

    and also using css to make the default links invisible:

    .post-navigation {
    display: none !important;
    }

    .cat-links {
    display: none !important;
    }

    The issue with this is that these links are visible from the page where you can see the exerts of all my posts. I don’t want to display these links here because it looks cluttered and is not needed. Any ideas?

    Much appreciated. Awesome software by the way!

    • This topic was modified 8 years, 1 month ago by karl.
    #178987
    karl

    Manage to solve this by changing this a bit: https://gist.github.com/generatepress/bb5a62c2a94b94bedad0 (setting to TRUE).

    How would I change it so that it has the arrow after next? At the moment it says >Next. I want it to say Next> Struggling to see how to do this.

    #179018
    karl
    #179027
    Tom
    Lead Developer
    Lead Developer

    Glad you found the solutions! Thanks for posting 🙂

    You can also achieve the category specific navigation with this filter instead of that entire function: https://generatepress.com/forums/topic/nextprevious-links-within-category-only/#post-157100

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