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
1 Answer
Reset to default 0within 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
评论列表(0条)