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?
You can do the following
$tag_id = get_queried_object()->term_id;
And then
$args = array(
'tag' => $tag_id,
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With