I've got a multi-author site running on Wordpress 3.1.3 .

I'm trying to place an extra header above the title for a specific author. So if "John" posts on the blog, it would have an above the post on the home page that says "John's Perpective", or something of that nature. The idea is that we want one of the many author's posts to be highlighted for users.

My issue is that I cannot figure out how to check for which user wrote the post within the loop. I am doing it on various other areas of the site via WP_Query.

I'm imagining I need something like this (pseudo code):

if ( author == 2 ) {
    echo '<h2>John's Perspective</h2>'

Should be an easy fix, but I'm stumped.

Thanks in advance!

3 Answers 3


When you're in the loop, you can use get_the_author() to get the author's 'Public' name. Alternatively, you can use get_the_author_meta( 'ID' ) in the loop to get the author ID.

So, modifying your psuedo-code:

if ( 2 == get_the_author_meta( 'ID' ) ) {
    echo '<h2>John's Perspective</h2>'
  • Thanks a lot! I ended up using this solution because I like IDing the authors by ID instead of name. Jun 22, 2011 at 19:19

You can use get_the_author() (Codex ref), which returns the author's display name. e.g.:

if ( 'John Smith' == get_the_author() ) {
    // This is a post written by John; do something

To use other author metadata, use get_the_author_meta() (Codex ref), e.g.:

$authormeta = get_the_author_meta();

if ( 'johnsmith' == $authormeta->user_nicename ) {
    // This is a post writeen by username 'johnsmith'; do something

if you want to show a bit more than the name of the author, there is this function in twentyten that you might want to use:

    <?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries  ?>
<div id="entry-author-info">
    <div id="author-avatar">
        <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentyten_author_bio_avatar_size', 60 ) ); ?>
    </div><!-- #author-avatar -->
    <div id="author-description">
        <h2><?php printf( esc_attr__( 'About %s', 'twentyten' ), get_the_author() ); ?></h2>
        <?php the_author_meta( 'description' ); ?>
        <div id="author-link">
            <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>">
                <?php printf( __( 'View all posts by %s <span class="meta-nav">&rarr;</span>', 'twentyten' ), get_the_author() ); ?>
        </div><!-- #author-link -->
    </div><!-- #author-description -->
</div><!-- #entry-author-info -->
<?php endif; ?>

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.