I am trying to display current post author link above the loop (before loop starts) with this tag the_author_posts_link() but it's not displaying the author post link. Anyone please help me.

Edited question:

So I want author post links like this

September 17th, 2008 by (here will be author name with post link)


September 17th, 2008 by Jatin Soni

This is the author meta I belive

  • use get_author_posts_url($id) instead..
    – Amit Kosti
    Aug 9, 2012 at 17:31
  • It's not working. May be I explained wrong but please check my edited question Aug 9, 2012 at 17:36
  • that is post date right ?
    – Amit Kosti
    Aug 9, 2012 at 17:38
  • Yes that's right I am trying to display post meta above the loop Aug 9, 2012 at 17:40

3 Answers 3


It make use of global variable $post to get author id of current post. Using that this function returns the author url.

Note -

Make sure you put this in condition ( is_single() ) so it only print author url on single.php.

<?php echo get_author_posts_url( $post->post_author ); ?>

Update -

<?php $username = get_userdata( $post->post_author ); ?>    
<a href="<?php echo get_author_posts_url( $post->post_author ); ?>"><?php echo $username->user_nicename; ?></a>

This will work, but I'll update my answer if I found more efficient method.

  • Its echo the actual url but I want the author name with its post link (archive) please check my edited question. Aug 9, 2012 at 17:37
  • I've updated answer, I'll update again if found more efficient method.
    – Amit Kosti
    Aug 9, 2012 at 18:01
  • This is what I was looking for. Thanks a lot Amit and Happy Janmashtami. Jai Shri Krishna :) Aug 9, 2012 at 18:11

You have to use the function in the loop.

Else it won't output anything.


First, you might want to retrieve a list of links to all authors.

All authors:

You can use wp_list_authors() for this:

$authors = wp_list_authors( array(
     'echo'       => false
    ,'feed_image' => false
    ,'feed'       => true
) );
// do something with ...
// $authors;

This leaves you with a list of all authors and is similar to what @amit wrote.

A single author link

This is similar to what @amit wrote.

Setup the user data with setup_userdata( $author_id );. The $author_id can be retrieved with the $post global like this:

global $post;
$author = setup_userdata( $post->post_author );
echo get_author_posts_url( $post->post_author, $author->user_nicename ); 
  • I know that but I want to display post author info above the loop for some reason. How can I do that? Aug 9, 2012 at 17:31
  • See update. @amit and me answered at pretty much the same time, so please mark his answer as solution (still appreciate an upvote).
    – kaiser
    Aug 9, 2012 at 17:40
  • This is giving url but I want author display name with link. Like September 17th, 2008 by Jatin Soni Aug 9, 2012 at 17:52
  • 1
    Amit's edited answer works but I really appreciate your help and effort so up voted :) thanks again Aug 9, 2012 at 18:12
   $author_name = get_userdata($author_id)- >display_name; 
   <a href="<?php echo get_author_posts_url(    get_the_author_meta( $author_id ) ); ?>"><?php.    echo $author_name; ?></a>
  • 1
    Please add an explanation to your code and how it works. Dumping of code as an answer is not recognized as an answer. May 29, 2014 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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