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

This code show tags from a specific category such as id = 3. I want to make automatically check which category I am. Can someone please help me ?

$args = array('categories'=> '3'); 
$tags = get_category_tags($args); 
$content .= "<ul>"; 
foreach ($tags as $tag) { 
    $content .= "<li><a href=\"$tag->tag_link\">$tag->tag_name</a></li>";
$content .= "</ul>"; 
echo $content; 
share|improve this question
up vote 1 down vote accepted

within a category you can use get_queried_object() to get data on the current category.

$current_category = get_queried_object();
$args = array( 'categories' => $current_category->term_id ); 
$tags = get_category_tags( $args ); 
share|improve this answer
thanks, but it's not working on single product page any idea? – Dime Nov 4 '12 at 9:13
I solve the problem for single page: <?php if ( is_singular('product') ) { $terms = wp_get_post_terms( $post->ID, 'product_cat' ); foreach ( $terms as $term ) $cats_array[] = $term->term_id; ?> – Dime Nov 4 '12 at 13:06
@Dime Please add that as separate answer. – kaiser Mar 11 '13 at 21:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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