Support » Plugins » Displaying author meta only when available

  • I’ve added some contact fields namely twitter, G+ and Facebook to the author profile page. What I wanted to do was only show them if in fact there was data. I’ve started with this but i always returns the else statement.

    <?php if ( get_the_author_meta('twitter') ) { ?>
    <p><?php the_author_meta('twitter'); ?></p>
    <?php }
    else { ?>
    <p>nothing here</p>
    <?php } ?>

    To be certain the data was there I tried

    <?php echo $curauth->twitter; ?>

    and that displays perfectly, so I know the data has been written to the database.

    So why is it the if else statement won’t work for me? Ideally I only want to show fields that have content in the author page.

  • The topic ‘Displaying author meta only when available’ is closed to new replies.