Support » Plugin: Ambrosite Next/Previous Post Link Plus » 'in_same_tax' => true (not working)

  • Resolved idowning


    I have made a list of rooms with custom post type. The rooms are split into two different groups using custom taxonomy (house and cottage). I would like the previous/next post to loop through only it’s particular taxonomy. I’m able to get the previous/next links to cycle through all of the rooms in my custom post type, it is just not limiting the loop to the particular custom taxonomy. When I add 'in_same_tax' => true to my array the link goes away (so I’m assuming it is not finding any other posts with the same taxonomy). I don’t know of a way to either see what taxonomy it is comparing to or if it is even seeing my custom taxonomy. (I am only using one custom taxonomy for the rooms custom post type)

    Any help would be greatly appreciated.


    Here is what my code looks like:

    <li class="postLink"><?php previous_post_link_plus( array(
    						 					'order_by'		=> 'menu_order',
    						 					'loop'			=> true,
    						 					'link'			=> '« Previous Room',
    						 					'before'		=> '',
    						 					'after'			=> '',
    						 					'format'		=> '%link',
    						 					'echo'			=> true
    						 					'in_same_tax'	=> true
    						 						) ); ?></li>
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author ambrosite



    The problem you are describing (in_same_tax not working with multiple custom taxonomies) is a known limitation of the plugin that I am planning to fix in the next version. I will be releasing the new version of the plugin shortly after the final release of WordPress 3.2, which I believe is supposed to happen toward the end of June. If you cannot wait that long, there is a temporary workaround that requires editing the plugin code. Let me know if you want the details on that.


    Thanks for the quick response. I really like this plugin and use it quite often.

    The workaround would be very helpful.


    I’m working on a project where I have a similar issue. Due to having multiple taxonomies the in_same_cat option and in_same_tax options are nto working. The temporary workaround you’ve found would be great, for now I’ll see if I can fix it myself.

    Plugin Author ambrosite


    Here is the fix for the multiple custom taxomony problem. Go to line 88 of the plugin (version 2.2). It should look like this:

    $tax_array = wp_get_object_terms($post->ID, $taxonomies, array(‘fields’ => ‘ids’)); // line 88

    The $taxonomies variable is the array of all custom hierarchical taxonomies. If you want to restrict in_same_tax to one specific taxonomy, replace that variable with the name of the taxonomy you want (that is, the name used in the first parameter of register_taxonomy):

    $tax_array = wp_get_object_terms($post->ID, ‘my_taxonomy’, array(‘fields’ => ‘ids’)); // assuming your taxonomy is named ‘my_taxonomy’

    My plan for the next version of the plugin is to let you specify a particular custom taxonomy using the in_same_tax parameter.

    Thank You ambrosite!!
    You’re solution worked perfectly!

    Plugin Author ambrosite


    The fix I described above should no longer be used. I have added the option to specify a custom taxonomy using the in_same_tax parameter. Version 2.3 is now available in the plugin directory; please check the documentation for usage details.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘'in_same_tax' => true (not working)’ is closed to new replies.