PHP 'if' Statement Printing to Screen (2 posts)

  1. cpuzzuol
    Posted 3 years ago #

    I have a custom author box on my site with a link to the author's Twitter handle. I am trying to create a conditional statement which only tells the user to follow the author on Twitter only when he/she actually has a handle. Below is the code for this...it's as you would expect.

    <?php if( the_author_meta('twitter')) : ?>
    Follow <?php the_author_meta('first_name'); ?> on Twitter
    <?php endif;?>

    Strangely, when I do this, I get the Twitter handle (and only the Twitter handle) from the author's meta data even when I remove everything between the 'if' statement. So, for example, if my Twitter handle is 'JoeShmo', when I add this 'if' statement I see "JoeShmo Follow Chris on Twitter". When I get rid of the code between the 'if' statement it displays 'JoeShmo'.

    Here is an example on my live site of the author box:
    http://www.emugermanalumni.org/2012/08/24/follow-alysa-and-terry-all-year-long-in-giesen/#respond . Of course here it is working because I have a handle.

    Thanks in advance!

  2. Tarsem Singh
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic