Support » Fixing WordPress » get_the_tags if more than 0 (any)

  • Resolved boon_

    (@boon_)


    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Edit: fixed it now with this

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

    Whoops!

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_the_tags if more than 0 (any)’ is closed to new replies.