Help with get_the_tags
-
Trying to display code based on different tag values.
https://codex.www.ads-software.com/Function_Reference/get_the_tagsIf the post has the tag it works fine, it the post has no tags I get Warning: Invalid argument supplied for foreach().
<?php if ($all_the_tags); $all_the_tags = get_the_tags(); foreach($all_the_tags as $this_tag) { if ($this_tag->name == "Tag 1" ) { ?> <a href="<?php echo get_tag_link(78); ?>">Tag 1</a> <?php } else if ($this_tag->name == "Tag 2" ) { ?> <a href="<?php echo get_tag_link(79); ?>">Tag 2</a> <?php } else { ?> <!-- not tagged as one or the other --> <? } } ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Help with get_the_tags’ is closed to new replies.