The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Using author template tags *outside* of The Loop! (4 posts)

  1. RobotDan
    Posted 10 years ago #

    I want to have information of the author within the sidebar (sidebar.php). Unfortunately the template tags to retrieve this information must be within the loop (e.g. the_author, the_author_description)

    Can I store these while in The Loop within a php variable and then return in the sidebar? Or can you think of another way I may achieve this?

    Previously I achieved this by using the Get Author Profile plugin ( http://guff.szub.net/get-author-profile ), which has now stopped working after the upgrade to WordPress 2.0. The empty box on the right is where I want the info to go!

  2. Tijmen
    Posted 10 years ago #

    Found a solution (maybe).

    Insert this into the loop:

    global $authordata;
    $postauthorx = $authordata->ID;

    And this into that box:

    global $postauthorx;
    echo $postauthorx;
    $result = @mysql_query("SELECT meta_value FROM wp_usermeta WHERE user_id = $postauthorx AND meta_key = 'description'");
    while ($row = mysql_fetch_array($result)) {

    $description = $row["meta_value"];
    echo $description;
    } ?>

    But maybe there's an easier way...

  3. RobotDan
    Posted 10 years ago #

    Thanks a lot for your help, it works! Shame I don't know enough php to see why the Get Author Profile plugin no longer works.

  4. RobotDan
    Posted 10 years ago #

    I've used the above method to show the author info on a single article page, and now I'm trying to get it to show when you are viewing an author archive.

    I've tried the method here:

    ...but in WordPress 2.0 it doesn't return the nickname if it has more than one word.

Topic Closed

This topic has been closed to new replies.

About this Topic