The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

tag cloud of specific category page (1 post)

  1. vaneess
    Posted 3 years ago #

    Hi everybody

    just spent a few hours of searching and scripting and thought you might be looking for it to.
    i wanted a tag cloud on my category page, which only shows the tags used in the posts of this category.

    put this in your category.php file wherever you want it.
    (please make sure, not to lose this code with a WordPress update)

    	//get category name
    	$catname = get_category(get_query_var('cat'))->name;
    	//get all tags in this category
    	if (have_posts()) : while (have_posts()) : the_post();
            $posttags = get_the_tags();
    		if ($posttags) {
    			foreach($posttags as $tag) {
    				//Get Tag ID
    				$all_tags_arr[] = $tag -> term_id;
    	endwhile; endif;
    	//remove duplicates
    	$tags_arr = array_unique($all_tags_arr);
    	//get tag cloud with tag IDs in $tags_arr
    	$args = array('include'  => implode(',',$tags_arr) );

    hope this helped :)

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by vaneess
  • This topic is not a support question
  • WordPress version: 3.5.1