Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'd like to ONLY show the authors website link if it exists, but I can't work out the exact syntax for it.

I have this

        if ( get_the_author_meta('user_url') ) : // If a user has filled out their decscription show a bio on their entries

         echo  the_author_meta('user_url');

        endif;

But I need to wrap it in a link and give that link a class, like this

<a class="meta-website" href="<?php the_author_meta('user_url') ?>">Author's Website</a>

The problem is when I add another 'echo' before the_author_meta one it just breaks the site.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Try passing $user_ID global variable to function as following. it is working for me.

<?php 
  global $user_ID;
  if ( get_the_author_meta('user_url',$user_ID) ) : // If a user has filled out their decscription show a bio on their entries 
?>
  <a class="meta-website" href="<?php the_author_meta('user_url',$user_ID); ?>">Author's Website</a>    
<?php endif; ?>
share|improve this answer
    
EDIT - I'm an idiot, it does work, hehe. :) –  andy Mar 8 '13 at 10:31
add comment

I know this is answered, but for future reference, echo the_author_meta('user_url'); Won't work because the_author_meta() outputs the value, so you're trying to echo echo essentially.

You can echo get_the_author_meta() if you're going to keep it with the <?php ?>

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.