Ready to get started?Download WordPress


[resolved] Output Standard Text When Post Tags Are Empty (4 posts)

  1. gartlans
    Posted 3 years ago #

    If the author has not included a post tag in the post, is it possible to display a standard text description "No Tags Found"??? So if a post tag is found, display it, if not, then output standard text "No Tags Found"...

    I'm currently using in single.php;

    <p class="tags"><?php the_tags('Tags: ', ' | ', ''); ?>


  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    <?php if( get_the_tags() ) { ?>
    <p class="tags"><?php the_tags('Tags: ', ' | ', ''); ?></p>
    <?php } else { ?>
    <p class="tags">No Tags Found</p>
    <?php } ?>


  3. gartlans
    Posted 3 years ago #

    Thanks Alchymyth that's perfect!!! :) Thanks for taking the time to share your knowledge, I appreciate it...

  4. pmagony
    Posted 2 years ago #

    This is a quick fix, but if you want to do it at the root of the categories file, you need to open wp-includes/category-template.php

    Line: 536

    You'll find this:

    if ( empty( $tags ) || is_wp_error( $tags ) )

    Replace with this and customize your text to taste:

    if ( empty( $tags ) || is_wp_error( $tags ) ) {
    		echo "<p>There are currently no associated tags.</p>";

Topic Closed

This topic has been closed to new replies.

About this Topic