Home / loop / Display specific content if post has_tag or specific tag
  • How to Display specific content if post has_tag or specific tag

    display-specific-content-if-post-has_tag-or-specific-tag

    Adding this snippet within the loop of your wordpress template will let you display specific content if a post has tags or not. Also note that has_tag(‘tag_name’) suports, tag name, term_id or slug and an array of tag names, term ids and slugs. Also a big thanks to Jeremy for submitting the following.

    wordpress snippet : PHP

    <>
    <?php
    if(has_tag()){
        echo 'this post has tags';
        }else {
        echo 'no tags sorry';
    }
    ?>
    

    ( WordPress codex functions, hooks, in this snippet. )

    has_tag,