categories - show category in woocommerce

This code show tags from a specific category such as id = 3. I want to makeautomatically check which category I am. Ca

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; 

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 asked Nov 4, 2012 at 1:58 DimeDime 694 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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 ); 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745096861a4611031.html

相关推荐

  • categories - show category in woocommerce

    This code show tags from a specific category such as id = 3. I want to makeautomatically check which category I am. Ca

    12小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信