Storing single_tag_title in variable
archive, echo, tags, variables, wordpress
Solution
single_tag_title accepts two arguments. $prefix and $display. $prefix sets the string which should be echoed/returned before the tag, and $display determines whether the tag is echoed or returned as a variable. See the documentation here.
$tagSlug = single_tag_title("", false);
echo $tagSlug;
Problem
In Wordpress, the following will echo the currently chosen tag in an archive listing: ``` single_tag_title(); ``` Does anybody know how to store it in a variable, so that i can echo out the same string using an ordinary php variable like this: ``` echo $tagSlug; //This shows the same string as the single_tag_title() function ``` I have tried this: ``` $tagSlug = single_tag_title(); echo $tagSlug; ``` But it doesn't work.