0

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.

1

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; ?>
  • EDIT - I'm an idiot, it does work, hehe. :) – andy Mar 8 '13 at 10:31
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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