WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. gartlans
    Member
    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: ', ' | ', ''); ?>

    Thanks,

  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 } ?>

    http://codex.wordpress.org/Function_Reference/get_the_tags

  3. gartlans
    Member
    Posted 3 years ago #

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

  4. pmagony
    Member
    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 ) )
    		return;

    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>";
    		return;
    	}

Topic Closed

This topic has been closed to new replies.

About this Topic