WordPress.org

Forums

Ambrosite Next/Previous Post Link Plus
[resolved] 'in_same_tax' => true (not working) (7 posts)

  1. idowning
    Member
    Posted 3 years ago #

    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.

    Thanks.

    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>
  2. ambrosite
    Member
    Plugin Author

    Posted 3 years ago #

    idowning,

    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.

  3. idowning
    Member
    Posted 3 years ago #

    ambrosite,

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

    The workaround would be very helpful.

  4. farneman
    Member
    Posted 3 years ago #

    ambrosite,

    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.

  5. ambrosite
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  6. idowning
    Member
    Posted 3 years ago #

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

  7. ambrosite
    Member
    Plugin Author

    Posted 3 years ago #

    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.

    http://wordpress.org/extend/plugins/ambrosite-nextprevious-post-link-plus/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic