Forums

[resolved] get_the_tags if more than 0 (any) (3 posts)

  1. boon_
    Member
    Posted 3 years ago #

    I'm trying to output content depending on if there are any tags within a post (1 or more)

    I'm currently using this..

    <?php if (count(get_the_tags($post->ID))>0): ?>
    Content
    <?php endif; ?>

    ..but it's not working and returns for posts with or without tags.

    Anybody got a fix or another function I can use?

    Thanks

  2. boon_
    Member
    Posted 3 years ago #

    Edit: fixed it now with this

    <?php $testtags = get_the_tags($post->ID); if ($testtags): ?>
    Content
    <?php endif; ?>

    Whoops!

  3. nicktank
    Member
    Posted 2 years ago #

    There is an easier way to pull this off. I'm using WP 2.8 with php5. Not sure if these template tags are available in all versions

    `
    <?php if(get_the_tags('count>=1'); { ?>
    Print out some stuff here

    <?php } else { ?>

    this is results of there being no tags

    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic