Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

WordPress multiple taxonomies WordPress

Hi,

I have a website setup that has a custom post type of "newsroom", which within it has two taxonomies, one for "client" and the other for "tags".

Each client has it's own area that will display the posts for that client. Then within each post for a client, you can add a tags, which works in the same was as the default tags for WordPress.

I now need to develop an area on the website so that for a specific client area, it only shows the tags associated to there own area.

At the moment, I have all of the tags displaying, as seen below:

[code]

<?php
$myterms = get_terms('tags', $args);
$args = array('public'=>true,'_builtin' => false,'order'=>'ASC','hide_empty'=>false);
foreach($myterms as $term) { ?>
<?php $t_id = $term->term_id; ?>
<?php $term_meta = get_option( "taxonomy_$t_id" ); ?>
<option value="http://dev.clickymedia.co.uk/ipr/tags/<?php echo $term->slug; ?>"><?php echo $term->name; ?></option>
<?php } ?>

[/code]

Do you know of a way I can get those tags to display just specific client tags?

Thanks...

Answers (4)

2013-07-18

Arnav Joy answers:

how you are assigning particular term to particular client?


craigfarrall comments:

Both the tags and client are a taxonomy of the newsroom, but I just need to filter out the tags based on what client has been selected (the other taxonomy). Any ideas?

2013-07-18

webGP answers:

Hello!

I think, you can use only one hierarchical taxonomy - first level will be responsible for clients and second level will be responsible for tags for specific client, it sould be simple way to control relationship.


craigfarrall comments:

This website has been built for months and is the final thing remaining, so the taxonomy hierarchy will need to stay the same. Any ideas on how to do this as it currently is?


webGP comments:

Hi!

I don't know where you want to display these tags (which pages), but on on each page you probably can get specific client term id, so my only idea is get client id, get all posts (newsroom) for this client, and after that get all tags for these posts ids.

2013-07-18

Remy answers:

If I understand correctly, you want to show tags associated with the posts of a client ?

I think you can use this function [[LINK href="http://codex.wordpress.org/Function_Reference/wp_get_object_terms"]]http://codex.wordpress.org/Function_Reference/wp_get_object_terms[[/LINK]], but you'll need to create an array with the posts IDs associated with a client first.

2013-07-18

Luis Abarca answers:

I recently did a similiar thing:

1.- We added a custom field on the user profile with a list of "client" taxonomy terms.
2.- Administrator set a custom term for each user.
2.- When the user add new posts, that term taxonomy is added to the post on save_post hook, that way we can filter their posts.

Then when they browse the site, they see a filtered version with only posts belonging to their taxonomy (dont know if this apply to your site)