WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get author information in my header.php.

This is what I use to display the name and it works like a charm:

<?php $author_id=$post->post_author; ?><?php echo the_author_meta( 'display_name' , $author_id ); ?>

I also wanted to get the author's URL so I changed the code to

<?php $author_id=$post->post_author; ?><?php echo the_author_meta( 'user_url' , $author_id ); ?>

but this doesn't work.

share|improve this question
What are you hoping to get the author for? Which post? – shea Jan 9 '13 at 9:19

I just put a piece of code from author.php file of TwentyTwelve theme:

    /* Queue the first post, that way we know
     * what author we're dealing with (if that is the case).
     * We reset this later so we can run the loop
     * properly with a call to rewind_posts().

<header class="archive-header">
    <h1 class="archive-title"><?php printf( __( 'Author Archives: %s', 'twentytwelve' ), '<span class="vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( "ID" ) ) ) . '" title="' . esc_attr( get_the_author() ) . '" rel="me">' . get_the_author() . '</a></span>' ); ?></h1>
</header><!-- .archive-header -->

    /* Since we called the_post() above, we need to
     * rewind the loop back to the beginning that way
     * we can run the loop properly, in full.

Pay attention to how they get an author posts link. At the beginning they call the_post function outside the main loop to fetch first post. Then they get author information, like posts URL and display name. And finally they call rewind_posts function to reset loop.

You can use the same technique in your header.php file.

share|improve this answer

the_author_meta( 'user_url' ) will retrieve the website URL as set in the author's profile. You need to use the_author_meta( 'url' ) to display a link to the author post archive:

global $post;
$author_id = $post->post_author;
the_author_meta( 'url' , $author_id );

Also note that you don't need to echo anything, as the_author_meta() already displays it for you.

share|improve this answer
It is giving me page permalink – vaibhav Jan 9 '13 at 8:55
See my updated answer – shea Jan 9 '13 at 9:27
still the same giving me page permalink – vaibhav Jan 9 '13 at 14:27

You can use get_the_author_link() function to get the url pointing to the author.

Also you can use the_author_link() to display the author link.


You might get help with this.


global $post;
the_author_meta( $field, $author_id );
share|improve this answer
as i said i am using the codes outside the loop – vaibhav Jan 9 '13 at 8:56

Your Answer


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.