WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Access author data outside loop in sidebar (3 posts)

  1. TrishaM
    Member
    Posted 4 years ago #

    Having trouble with using author meta data outside the loop (in the sidebar) of a single post page. It works perfectly in the sidebar on Author page (using template author.php) but not on a single.php

    I have this outside the loop:

    <?php
    if(isset($_GET['author_name'])) :
    $curauth = get_userdatabylogin(get_the_author_login());
    else :
    $curauth = get_userdata(intval($author));
    endif;
    ?>

    If I use that in the sidebar on author.php it works perfectly and I can access all the author meta data (e.g. $curauth->aim; )

    BUT if I use it in the sidebar on single.php to access the author meta data for the author of that particular post, it doesn't give me the correct author data, it gives me MY data even though I am not the author of the post.....

    Any ideas?

  2. MichaelH
    Member
    Posted 4 years ago #

    $posts[0]->post_author will contain the author id of a post when in single view.

  3. TrishaM
    Member
    Posted 4 years ago #

    Fabulous - MichaelH YOU ROCK!

    Thanks for your help - that fixed my problem!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.