Forums

How to test if a post has tags? (2 posts)

  1. futurosity
    Member
    Posted 2 weeks ago #

    How can I write a simple conditional statement to test if a post has tags? I want to hide part of my layout if the tags for a post are empty.

  2. Alphawolf
    Member
    Posted 1 week ago #

    A wild shot:

    <?php
    $hastags = get_the_tags();
    if ( $hastags ) {
      //Your elements when post has tags
    }
    ?>

    Not tested.

Reply

You must log in to post.

About this Topic