WordPress.org

Forums

[resolved] Get Author Profile - Dynamically calling auth_ID (8 posts)

  1. vavroom
    Member
    Posted 10 years ago #

    I've found the Get Author Profile plugin, which is great, except for one thing. I can't figure out how to pass the author id automatically based on the post's author...

    I have several authors on a blog, and want to display a mini profile in the sidebar, when the post is viewed on single.php. I can call the plugin's code conditionally with is_single.

    I can pass the author ID to a variable within the loop. But I can't seem to use that variable in the plugin's function.

    Any ideas, anyone? I really can't afford to hard code the author id in the function. I don't want to create an author.php page. I feel a tad stuck.

    Cheers

  2. Alex Mills (Viper007Bond)
    Moderator
    Posted 10 years ago #

    Does your sidebar come before or after the Loop on your site?

    If it comes after, then just save the author's ID to a variable inside the Loop and global it. Then do into your sidebar, global it there too and then call it. :)

  3. vavroom
    Member
    Posted 10 years ago #

    Thanks Viper,

    Yes, the sidebar comes after the loop.

    I'm not sure how you "global" a variable. And (showing my ignorance here), if REGISTER_GLOBAL is turned off at server level, will that impact "globaling the variable"?

  4. Alex Mills (Viper007Bond)
    Moderator
    Posted 10 years ago #

    In your Loop:

    global $theauthorID;
    $theauthorID = get_the_author_ID();

    In your sidebar:

    global $theauthorID;
    somefunction($theauthorID);

    I think that will work. :)

    If not, you could probably have a 2nd Loop in your sidebar that doesn't output anything. Just have it grab the ID and then end.

  5. vavroom
    Member
    Posted 10 years ago #

    Viper, you be da (wo)man. Thanks mate :)

  6. Alex Mills (Viper007Bond)
    Moderator
    Posted 10 years ago #

    Man and you're welcome. :)

  7. vavroom
    Member
    Posted 10 years ago #

    Cool. ta.

  8. suleiman
    Member
    Posted 9 years ago #

    Any way to insert the requisite code into "The Loop" of multiple themes without having to edit each theme manually?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.