Support » Fixing WordPress » Switch out of category.php to single.php

  • I have a unique situation (I think). when a user clicks on a category and views the initial post in category.php, what I want to do is make it so the next/previous buttons in category.php push them into single.php (so instead of clicking next to stay in category.php view of the posts, I want to switch the user to single.php. In other words, i want them to go into using the actual permalink for the posts, not stay within the permalink structure of category.

    I want to do this because I want category markers to be used like chapter markers, but I want the user to then move within all of the posts, not just stay stuck within one category.

    next-posts-link won’t do it, and next-post-link doesn’t work in category.php. I could get the current permalink and add 1 to it, but that could result in weird behavior if a post was deleted or is in a category outside of the main one I want them in.

    I was sort of assuming I’d need to do a custom loop declaration–but am not sure how to base it off the current post to determine the next and previous links (in reality, I only need to get the next link since once they click it they’ll be in the single.php view).

    Any idea how I can get this to work?

    As a corollary–is there a way to force clicking a category link to initially go to the single.php view of the linked post instead of the category.php view? That’s what I’d really like to happen…

  • The topic ‘Switch out of category.php to single.php’ is closed to new replies.