WordPress: How to get pagination to work in parent and child category
# April 18, 2013 at 3:30 pm
I have a parent category titled ‘Latest’ and its children categories titled ‘Painting,’ ‘Illustration,’ ‘Photography,’ etc. I’m using the following code in my single.php page from [Wordpress Codex](http://codex.wordpress.org/Template_Tags/next_post_link “http://codex.wordpress.org/Template_Tags/next_post_link”) to get the pagination to flip through posts within the same child category. All works well.
< ?php previous_post_link('%link', 'Previous', TRUE); ?>
< ?php next_post_link('%link', 'Next', TRUE); ?>
However, when I enter the post from the parent category, it reverts back to flipping through posts within the child category it pertains to, not the parent. I was hoping to get it to work for parent too. Apparently, it confuses visitors.
I was suggested to use [Ambrosite Next/Previous Post Link Plus](http://wordpress.org/extend/plugins/ambrosite-nextprevious-post-link-plus/ “http://wordpress.org/extend/plugins/ambrosite-nextprevious-post-link-plus/”) plugin, but it doesn’t seem to help my problem.
I’ve been trying really hard to get this to work (with and without plugin) but with no luck. I thought it would be simple to do. If anyone can help me, I’d greatly appreciate it!# April 18, 2013 at 5:02 pm
I seem to have solved the problem. Use the code above from WordPress Codex. Then make sure that each post has child and parent categories checked off when managing each post.
I only had child category checked off which is probably why the pagination wasn’t working correctly when entering a post from the parent category.
Simple solution. Not sure why I didn’t see that. Sorry about that.# April 23, 2013 at 1:30 pm
I thought I solved the problem but I just realized I didn’t. Now that I have both child and parent categories checked off, when entering the post from the child category, it flips through the parent category.
I learned and tried using Sessions and Taxonomies but it didn’t work. Then again I’m very new to Sessions and Taxonomies so maybe I’m not understanding something.
Again, I’m trying to get the next/previous post links to work within the same category for child and parent. Is this possible?
You must be logged in to reply to this topic.