Post navigation buttons only for specific posts in some categories

Hi there,

Is there a way to allow post navigation buttons (at the bottom of the post content) to only be visible to a certain category?

Basically, I’m using one of the post categories exclusively for the home page slider and another one for articles; such post navigation buttons would only make sense in article pages. Is there a way to solve this?



One thing would be to use WordPress conditional tags like described here.

Other solution would be to hide post navigation globally using CSS and then make it visible only based on category.

Here is an example that you can use via Appearance >> Theme Options >> Other >> Custom CSS:

.single {
  display: none;

.category-featured + {
  display: block !important;

This code will hide post navigation on all posts except “featured” category. You can target other categories by modifying code based on what categories you are using on your website. So this code won’t work by default and you need to use your own categories from your own website.

Hey, Aigars, tk u so much for the quick response!

I’ve adjusted the CSS code. So currently whenever I’m at a post page, post navigation is only visible if the post presented belongs to the category I’ve defined in the CSS code. But I still have an issue. If the “next”/“previous” post is from a different category, the navigation link will still appear - is there a way to hide a post navigation link based on its destination (aka category it belongs to).

Tks once again! :slight_smile:


To make post navigation button to work within the same category only you need to specify it for previous_post_link function that you can see defined inside template-tags.php file that you can find in Sparkling folder >> inc.

Here you can read more about previous_post_link function and how you should modify it. The same approach you should use for next_post_link.

Basically you just need to add ,TRUE before the closing brackets for each function.

Let me know if this helps.

good morning,

I’m using Travelify free template. Where can i find previous/next post_link function?


This thread is related to Sparkling theme but you are using Travelify theme. Also this thread is marked as resolved.

Please start your own thread and we will help you from there.

Sorry for inconvenience.

I’m using Sparkling theme.
How I can remove " Post navigation " h1 tag?
H1 tag is very important for SEO , But there is this problem in the template.
Thank you.

@webhosting This is old topic and to help us keep support thread separates could you please create your own thread for your question here instead of replying on others thread as it makes the thread messy and hard to read.

If you want to you can also add reference of this thread in your newly created thread.

We would be more than happy to help you on your new thread.