Category Navigation
-
Hey,
Loving this plugin, as I am turning my installation into a comic management system, so the default navigation links won’t cut it.
On my single.php and index.php pages, I am using the plugin to navigate between all published posts, like so:
<div class="navbar"> <span class="navlink"><?php if (!previous_post_link_plus(array('format' => '<< %link', 'tooltip' => '%title', 'end_post' => true, 'link' => 'First')) ) { echo '<span class="inactive"><<First</span>'; } ?></span> <span class="navlink"><?php if (!previous_post_link_plus(array('format' => '< %link', 'tooltip' => '%title', 'end_post' => false, 'link' => 'Previous')) ) { echo '<span class="inactive"><Previous</span>'; // if there are no older articles } ?></span> <span class="navlink"><a href="<?php the_permalink(); ?>#comments" title="Comments"><Comments></a></span> <span class="navlink"><?php if (!next_post_link_plus(array('format' => '%link >', 'tooltip' => '%title', 'end_post' => false, 'link' => 'Next')) ) { echo '<span class="inactive">Next></span>'; } ?></span> <span class="navlink"><?php if (!next_post_link_plus(array('format' => '%link >>', 'tooltip' => '%title', 'end_post' => true, 'link' => 'Last')) ) { echo '<span class="inactive">Last>></span>'; } ?></span> </div>
However, I also want to use the plugin to navigate within certain categories of comic posts, so I am using the in_same-cat attribute in my array on the archive.php page, like so:
<div class="navbar"> <span class="navlink"><?php if (!previous_post_link_plus(array('format' => '<< %link', 'in_same_cat' => true, 'tooltip' => '%title', 'end_post' => true, 'link' => 'First')) ) { echo '<span class="inactive"><<First</span>'; } ?></span> <span class="navlink"><?php if (!previous_post_link_plus(array('format' => '< %link', 'in_same_cat' => true, 'tooltip' => '%title', 'end_post' => false, 'link' => 'Previous')) ) { echo '<span class="inactive"><Previous</span>'; // if there are no older articles } ?></span> <span class="navlink"><a href="<?php the_permalink(); ?>#comments" title="Comments"><Comments></a></span> <span class="navlink"><?php if (!next_post_link_plus(array('format' => '%link >', 'in_same_cat' => true, 'tooltip' => '%title', 'end_post' => false, 'link' => 'Next')) ) { echo '<span class="inactive">Next></span>'; } ?></span> <span class="navlink"><?php if (!next_post_link_plus(array('format' => '%link >>', 'in_same_cat' => true, 'tooltip' => '%title', 'end_post' => true, 'link' => 'Last')) ) { echo '<span class="inactive">Last>></span>'; } ?></span> </div>
This appears to be working fine when I first enter a category archive. Initially, the links only point to posts within that category. However, once I have clicked a navigation link, the post appears to be displayed using the single.php template, so the navigation restricted to a single category is suddenly broken.
What am I missing here?
For example, visit this link to see the ‘PentaPrompted’ category archives: https://acommonlanguage.net/wp_test/category/pentaprompted/
Now click on ‘First’ to navigate within that category.
Then click on ‘Last’, which should theoretically take you to the last post within this same category. Instead, you will be taken to the most recent post, regardless of category.
How do I fix this so that navigation from a category archive stays within that archive?
https://www.ads-software.com/plugins/ambrosite-nextprevious-post-link-plus/
- The topic ‘Category Navigation’ is closed to new replies.