WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Link displayed with author's name (8 posts)

  1. Fmustang
    Member
    Posted 8 years ago #

    Sorry if my question seems stupid but I am new to WordPress and couldn't perform a search related with my question.
    The blog from wordpress.org is displaying the name of the article author with a link to their website. I have been searching my own website to do the same thing but didn't find anything. Do I have to install a plug in or do I have to modify the theme?
    Thank you in advance.
    My website: Ford Mustang blogs

  2. MichaelH
    Member
    Posted 8 years ago #

    The Codex article Template_Tags/the_author_url has an example of creating a link to an author's web-site.

    Other information:
    Templates
    Category:Template_Tags
    Category:Templates

  3. Modify the theme. Replace <?php the_author() ?> with this:

    <?php if (get_the_author()) { ?><a href="<?php the_author_url(); ?>"><?php the_author(); ?></a><?php } else { the_author(); } ?>

  4. Fmustang
    Member
    Posted 8 years ago #

    Thank you very much for your help. I got it working in 2mn :)

  5. Er, sorry, my code should be this:

    <?php if (get_the_author_url()) { ?><a href="<?php the_author_url(); ?>"><?php the_author(); ?></a><?php } else { the_author(); } ?>

  6. Fmustang
    Member
    Posted 8 years ago #

    I replaced the code but didn't see any diference on my pages. Can you tell me what was wrong with the first one?

  7. MichaelH
    Member
    Posted 8 years ago #

    Actually, as long as you had an author name and a website (url) then you wouldn't see a difference. But, the 2nd example is more correct as Viper007Bond is testing to see if there is a url before he actually puts it in a link otherwise it just defaults to displaying the author name without a link.

  8. Fmustang
    Member
    Posted 8 years ago #

    Thanks a lot Michael for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic