Support » Plugins » I am trying to figure out why this code doesn’t work

  • Resolved gregbd

    (@gregbd)


    I am a newbie and would like some help trying to figure out how to troubleshoot why this code does not pull any data.


    <?php
    if(get_query_var('author_name')) :
    $curauth = get_userdatabylogin(get_query_var('author_name'));
    else :
    $curauth = get_userdata(get_query_var('author'));
    endif;
    ?>

    <h1>About: <?php echo $curauth->nickname; ?></h1>
    <dl>
    <dt>Full Name</dt>
    <dd><?php echo $curauth->first_name. ' ' . $curauth->last_name ;?></dd>
    <dt>Website</dt>
    <dd>user_url; ?>"><?php echo $curauth->user_url; ?></dd>
    <dt>Details</dt>
    <dd><?php echo $curauth->description; ?></dd>
    </dl>

Viewing 4 replies - 1 through 4 (of 4 total)
  • Kafkaesqui

    (@kafkaesqui)

    I haven’t tracked down why, but on some setups get_query_var() doesn’t seem to work for this.

    Try this bit of code instead for grabbing the user data (in the author query template, assumedly):

    <?php
    global $wp_query;
    $curauth = $wp_query->get_queried_object();
    ?>

    EDIT: Made a small change to remove redundancy in the code.

    Thread Starter gregbd

    (@gregbd)

    Kafkaesqui: that worked like a charm! Thanks a lot!

    sadish

    (@sadish)

    that works for me too.

    Kafkaesqui

    (@kafkaesqui)

    Thanks for the updates. I’ve added it to the Codex page on the author template:

    http://codex.wordpress.org/Author_Templates

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘I am trying to figure out why this code doesn’t work’ is closed to new replies.