Question by WordPress.
Is it possible to display text on the single post page that changes depending on which tag is specified for the post. If the entry refers to a specific TAG, which is specified in the specified associative array, then the corresponding TEXT tag should be displayed. I know in WordPress there is a has_tag()
function that checks if a tag is related to this has_tag()
.
For example,
if ( has_tag('TAGNAME') ) { <p>выводиться TEXT для тега TAGNAME </p> elseif ( has_tag('TAGNAME1') ) { <p>выводиться TEXT1 для тега TAGNAME1 </p>
and so on (different tags and texts everywhere)
But how to do it programmatically? Not to write elseif constructions every time ?! Especially when there are a lot of tags. Is it possible to represent all this as an array?
$test = array('TAGNAME' => 'TEXT', 'TAGNAME1' => 'TEXT1')
And so that the verification of the tag through the has_tag
method is has_tag
, and the necessary text is displayed? But how about to do it?
Thank you in advance.