WordPress category sensitive page navigation


Many WordPress themes, including Suffusion, show links to next and previous posts by default. This is a nice feature to have but in my opinion not a deal-breaker if it is missing. One thing that annoyed me a bit was that those links were not category sensitive. I do have many different unrelated content categories on my site. Showing totally unrelated next and previous post links are not likely to attract many clicks. Fortunately modifying those links to be category dependant is not a big problem. Maybe even Suffusion has some settings for that. I did not find those options, if they are there. I usually get lost in Suffusion options šŸ™‚

Steps to make next and previous post links category sensitive:

Locate post template. File named single.php usually, if all post use one, default, template.

LocateĀ  previous_post_link(‘%link’, ‘%title’) in that post template and modify it to look likeĀ Ā previous_post_link(‘%link’, ‘%title’,TRUE).

Repeat it for next_post_link. That is it.

First and second argument to _post_link must not be %link and %title, but they usually are. Leave them as they are.

Link to wordpress documentation is here.

Leave a comment

Your email address will not be published. Required fields are marked *