Forums

Display all tags for a category (7 posts)

  1. alturo
    Member
    Posted 2 years ago #

    Hi I would like to show a list of tags used in a certain category, any tip?

    Thanks in advance!

  2. scribu
    Member
    Posted 2 years ago #

    You will need a plugin for that. Not sure there is one yet.

  3. canadian-dutch
    Member
    Posted 2 years ago #

    did you ever figure this out? I am trying to do this also

  4. multisai
    Member
    Posted 2 years ago #

    Hi

    http://localhost/wordpress/?cat=12
    how to get the query parameter value "cat=3"?
    please help me.

    Thanks. Sai

  5. haryadimas
    Member
    Posted 2 years ago #

    Hi, i've been looking for this for ages and i think i just found the solution.
    I'm only using wp_tag_cloud() which is already available in wordpress.
    I got the idea from http://wordpress.org/support/topic/238953?replies=1

    <?php
    
    //the id of the category you want
    $category_id = 4;
    
    $post_ids = get_objects_in_term( $category_id, 'category' );
    $tag_ids = wp_get_object_terms( (array) $post_ids, 'post_tag', array('fields' => 'ids') );
    $tag_param = '';
    if ( ! empty($tag_ids) ) {
    //change 'include=' to 'exclude=' to achieve the opposite..
    $tag_param = 'include=' . implode(',', (array) $tag_ids );
    }
    
    //format the output using wp_tag_cloud parameters
    wp_tag_cloud('number=0&amp;largest=12&amp;biggest=12&amp;unit=px&amp;format=list&amp;'.$tag_param);
    
    ?>

    the only thing missing is the post count in a bracket at the end of each tags..

  6. canadian-dutch
    Member
    Posted 2 years ago #

    I'd like to try your solution, can you tell me where I would put that code?

  7. pedroliveira
    Member
    Posted 2 years ago #

    thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic