• 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/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author ambrosite

    (@ambrosite)

    The plugin is not meant to be used on category archive pages. If you want to restrict navigation by categories you need to set the ‘in_same_cat’ parameter in single.php.

    Thread Starter KarlCraven

    (@karlcraven)

    Thanks. That’s a damn shame, as that would mean people would only be able to navigate a single category of comics on my website.

    I’m not sure why anyone would want to set their blog up that way. If you’re only letting people navigate through a single category, then you probably only have one category set up (otherwise, how would anyone ever see your posts in the other categories?). In which case, why use the category taxonomy at all? Or am I missing something?

    Okay, I will have to look for an alternative method of setting up First and Last navigation links for my archive page, I guess.

    Thanks for your prompt response.

    Plugin Author ambrosite

    (@ambrosite)

    Check out this thread. It will give you some idea of what needs to be done in order to get the effect you want.

    https://www.ads-software.com/support/topic/plugin-smarter-navigation-how-to-link-prevnext-post-in-parent-category?replies=49

    Thread Starter KarlCraven

    (@karlcraven)

    Okay, thanks. I’m going to investigate some alternatives before I get into that, as I am not using a Parent category, and I’m having a hard time understanding the code in that thread right now.

    Plugin Author ambrosite

    (@ambrosite)

    I know the details are not exactly the same, but the basic principle — using PHP sessions to track which link the user clicked on some previous page — could be used to solve your problem.

    Thread Starter KarlCraven

    (@karlcraven)

    Yeah, that sounds plausible. I just don’t have the php experience to figure this out right now.

    Thanks, though.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Category Navigation’ is closed to new replies.