With
$tag = single_tag_title('', false);
I can get the name of the currently chosen tag. Right?
But how can I get also the ID of the chosen tag? "single_tag_id" does not exist. And afterwards I would like to show only posts with the tag-id.
$args = array(
'tag' => 'ID HERE?',
);
But I can not put a number into 'tag'. How can I filter with tag-id and not do it by name?
答案 0 :(得分:4)
您可以执行以下操作
$tag_id = get_queried_object()->term_id;
然后
$args = array(
'tag' => $tag_id,
);