Support » Fixing WordPress » PHP 'if' Statement Printing to Screen

  • 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: . Of course here it is working because I have a handle.

    Thanks in advance!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘PHP 'if' Statement Printing to Screen’ is closed to new replies.