WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sorry if this has already been asked, but I am attempting to limit a list of tags to one category, in a couple different spots on my web page. I have this code:

    $tags = get_tags();
    $tags_count = count($tags);
    $percolumn = ceil($tags_count / 3);

    for ($i = 0;$i < $tags_count;$i++):
    if ($i < $percolumn):
    $tag_left .= '
<li><a href="'. get_tag_link($tags[$i]->term_id) . '"rel="tag">' . $tags[$i]->name .'</a></li>
    ' . "\n";
    elseif ($i >= $percolumn && $i < $percolumn*2):
    $tag_mid .= '
<li><a href="'. get_tag_link($tags[$i]->term_id) . '"rel="tag">' . $tags[$i]->name .'</a></li>
    ' . "\n";
    elseif ($i >= $percolumn*2):
    $tag_right .= '
<li><a href="'. get_tag_link($tags[$i]->term_id) . '"rel="tag">' . $tags[$i]->name .'</a></li>
    ' . "\n";
    <?php echo $tag_left; ?>

    <?php echo $tag_mid; ?>

    <?php echo $tag_right; ?>

How can I leverage this, and restrict the query to just one category.

share|improve this question

closed as too localized by toscho Feb 18 '13 at 23:38

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

You say one category, but yet you are using get_tags which only deals with post_tags. Please clarify your question. – Kevin Langley Jr. Nov 8 '11 at 20:31

You can easily do this without a plugin, but you would need to get all the posts with that specific category and then loop through those to get the tags of each of those specific posts.

share|improve this answer
I am a little new to php, and trying to wrap my head around all of this. Do you have any documentation you could point me towards to get this started? Any help would greatly appreciated. – Atticus Nov 9 '11 at 18:13
Nevermind I found the appropriate code here: stackoverflow.com/q/5321373 – Atticus Nov 9 '11 at 19:19

I was trying to do this exact thing a day or two ago. I ended up using the plugin/widget: http://wordpress.org/extend/plugins/simple-taxonomy/

It allows you to create custom taxonomies, and includes a tag cloud/list limited to whatever category you choose. And other things, but I've only used those two. Easy to style with CSS and worked right away.

Hope that helps.

share|improve this answer
dmoz do you know if this plugin allows me to do this on different pages to different categories, or is it a one size fits all. – Atticus Nov 8 '11 at 22:36
Kevin I am trying to list out the posts from a single category. For example, I have category x, and I want all the tags that are associated with category x only. – Atticus Nov 8 '11 at 22:38
Apologies, I meant the SensitiveTagCloud: wordpress.org/extend/plugins/sensitive-tag-cloud – dmoz Nov 9 '11 at 0:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.