WordPress.org

Support

Support » How-To and Troubleshooting » Next & Previous links for single taxonomy term?

Next & Previous links for single taxonomy term?

  • dtribble
    Participant

    @dtribble

    I need a way to display next/previous post links which only show posts which share a specific taxonomy term.

    I have a portfolio site I’m building which has a taxonomy called “expertise”. Under that taxonomy, there are several terms such as “branding”, “packaging”, etc. A project in the portfolio can have more than one taxonomy term applied to it. For example, a project could be a branding, identity, and packaging project.

    I’ve created a custom post type for projects in the portfolio and have built a template for displaying individual projects. I would like to be able to have next/previous post links only show posts which share a specific taxonomy term. I can pass this term from the querystring (i.e. http://mysite.com/myproject/?expertise=branding) but don’t know how to restrict the next/previous links to that specific term. The fact that a project can share several terms makes this difficult.

    I’ve tried the following plugins but they can’t seem to restrict the next/prev links to ONE term. Instead, they will include other projects which share any of the terms for the current project.

    Previous and Next Post in Same Taxonomy:
    http://www.billerickson.net/previous-and-next-post-in-same-taxonomy/

    Next/Previous Post Link Plus for WordPress:
    http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress

    I’m discussing my issue with each of the plugin authors so it may be that one of these will do what I’m hoping for and I’m just not understanding. I’ll update this thread if this is the case.

    In the meantime, if anyone has a solution for me, I would appreciate it. I’m guessing this may be able to be done with a custom query but my SQL chops aren’t quite up to it.

    Thanks for any help you can offer.

    -Damon

Viewing 4 replies - 1 through 4 (of 4 total)
  • trixienolix
    Member

    @trixienolix

    Damon did you ever get this to work? I also need next and previous within a taxonomy term. I’ve tried the answer given on teh ambrosite website but still no joy. How did you do it?
    http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress

    dtribble
    Participant

    @dtribble

    Hi trixienolix,

    Yes, I did figure out a solution. I need to go back to that project to see what I did. I’ll look later today and will update this thread…

    -Damon

    Hey Damon

    Would you be able to post the solution. I am stuck with the same problem and can’t get around it.

    Cheers

    Using Next/Previous Post Link Plus for WordPress:
    http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress

    I ended up including the prev/next as an external file in my single-portfolio.php file

    <?php include (TEMPLATEPATH . '/inc/portfolio-prev-next.php' ); ?>

    And in the portfolio-prev-next.php file:

    <div class="leftarrow"><?php previous_post_link_plus( array(
    		'order_by' => 'post_name',
    		'order_2nd' => 'post_date',
    		'meta_key' => '',
    		'post_type' => '',
    		'loop' => true,
    		'end_post' => false,
    		'thumb' => false,
    		'max_length' => 0,
    		'format' => '%link',
    		'link' => '<img src="images/leftarrow.png" alt="Next" />',
    		'date_format' => '',
    		'tooltip' => '%title',
    		'in_same_cat' => true,
    		'in_same_tax' => true,
    		'in_same_format' => false,
    		'in_same_author' => false,
    		'in_same_meta' => false,
    		'ex_cats' => '',
    		'ex_cats_method' => 'weak',
    		'in_cats' => '',
    		'ex_posts' => '',
    		'in_posts' => '',
    		'before' => '',
    		'after' => '',
    		'num_results' => 1,
    		'return' => ''
    		) ); ?>
    </div>
    <div class="rightarrow"><?php next_post_link_plus( array(
    		'order_by' => 'post_name',
    		'order_2nd' => 'post_date',
    		'meta_key' => '',
    		'post_type' => '',
    		'loop' => true,
    		'end_post' => false,
    		'thumb' => false,
    		'max_length' => 0,
    		'format' => '%link',
    		'link' => '<img src="images/rightarrow.png" alt="Next" />',
    		'date_format' => '',
    		'tooltip' => '%title',
    		'in_same_cat' => true,
    		'in_same_tax' => true,
    		'in_same_format' => false,
    		'in_same_author' => false,
    		'in_same_meta' => false,
    		'ex_cats' => '',
    		'ex_cats_method' => 'weak',
    		'in_cats' => '',
    		'ex_posts' => '',
    		'in_posts' => '',
    		'before' => '',
    		'after' => '',
    		'num_results' => 1,
    		'return' => ''
    		) ); ?>
    </div>

    The settings for in_same_cat and in_same_tax did the trick. Hope this helps.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Next & Previous links for single taxonomy term?’ is closed to new replies.