• Hey – I’m new to wordpress, naturally, and have searched high & low for a way to display a “current author” on an authors’ archive page.

    I understand how to get an author name displayed within the loop, but cannot find anything for displaying an author name outside of the loop (author name at top of page). There’s got to be a simple way that I’m merely overlooking.

    The closest I can come is by using the get-author-profile plugin: http://guff.szub.net/2005/01/31/get-author-profile/

    But it seems as though this should be doable without a plugin. Thanks.

Viewing 6 replies - 61 through 66 (of 66 total)
  • Kafkaesqui wrote:
    “Here’s all the author profile data you could access this way:

    $curauth->user_aim;
    $curauth->user_email;
    $curauth->user_firstname;
    $curauth->user_icq;
    $curauth->user_lastname;
    $curauth->user_level;
    $curauth->user_login;
    $curauth->user_msn;
    $curauth->user_nickname;
    $curauth->user_description;
    $curauth->user_url;
    $curauth->user_yim; “

    I’m fairly new to WP and very new to php. What syntax would I use for an if statement to check if any of these data items has a value, before echo it? Thanks

    This is the way it worked on my blog:

    <?php if(isset($_GET[‘author_name’])) : $curauth = get_userdatabylogin($author_name);
    else : $curauth = get_userdata($author);
    endif;
    ?>
    <?php echo $curauth->user_firstname; ?> <?php echo $curauth->user_lastname; ?>
    <?php echo $curauth->user_description; ?>

    You should also take a look at Kaf’s (http://szub.net/) “Get Author Profile” Plugin.

    Hope this helps

    Hi, I was trying to override my default admin setting -> 2 posts displayed per page for the archive (by author) template.
    So I tried the get_posts command. The loop I tried does not work, the post_author=$curauth->ID is not working. Could you tell me what I did wrong please?

    Here’s the code I used:

    <html>
    <body>
    <?php get_header(); ?>
    <div id=”content” class=”narrowcolumn”>
    <!– This sets the $curauth variable –>
    <?php
    if(isset($_GET[‘author_name’])) :
    $curauth = get_userdatabylogin($author_name);
    else :
    $curauth = get_userdata(intval($author));
    endif;
    ?>

    <h2>Posts by <?php echo $curauth->nickname; ?>:</h2>

    <!– The Loop –>

      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    • ” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”>
      <?php the_title(); ?>
      ,
      <?php the_time(‘d M Y’); ?> in <?php the_category(‘, ‘);?>
    • <?php the_excerpt(); ?>

      <?php endwhile; else: ?>
      <?php _e(‘No posts by this author.’); ?>

      <?php endif; ?>
      <!– End Loop –>

      <div class=”navigation”>
      <div class=”alignleft”><?php posts_nav_link(”,”,’« Previous Entries’) ?></div>
      <div class=”alignright”><?php posts_nav_link(”,’Next Entries »’,”) ?></div>

      </div>

    </div>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    </body>
    </html>

    I need to display author name of post at blog’s header(header.php).
    I don’t know why functions/plugins posted here, did not work for my blog.

    Currently I use WP 2.0.3 and RevvedUp Theme. hosted at dreamhost.

    Any advice ?

    My advice: Start a new thread. You’ll get noticed.

    Here’s how I got it running in my header (WP 2.0.5).

    By the way, I’ll be releasing this in a new “AutoSEO” theme later in the week probably — you can see it running already on my sister’s site, http://www.atlantarealestateforum.com. Just working out some bugs.

    Back to business:

    ***all of the following takes place in header.php***

    For the title, you’re going to have some conditionals, for instance:

    (Fingers crossed — I’ve never tried to put code in a forum before…)


    <?php
    if ( is_single() )
    {
    ?>
    <title>
    <?php wp_title(' '); ?>
    <?php if(wp_title(' ', false)) { echo ' | '; } ?>
    <?php bloginfo('name'); ?>
    </title>
    <?php
    }
    else
    {
    if(is_home())
    { ?> <title><?php bloginfo('name'); ?> | <?php bloginfo('description'); ?> | <?php wp_title(); ?></title>
    <? }

    elseif (is_category(''))
    { ?> <title><?php single_cat_title(); ?> | <?php bloginfo('name'); ?></title>
    <?php }

    Now we’re going to set up a new conditional (‘elseif’) for your author.php file, placing it somewhere after the above code but BEFORE your ‘else’ statement that ends your <title>-tag conditionals…

    …and I’m sure there’s a ‘prettier’ way to code this…


    elseif (is_author(''))
    {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    if(isset($_GET['author_name'])) : $curauth = get_userdatabylogin($author_name);
    else : $curauth = get_userdata($author);
    endif;
    ?>
    <title><?php echo $curauth->display_name; ?> | Posts by author | <?php bloginfo('name'); ?></title>
    <?php }

    You can then use <?php echo $curauth->display_name; ?> elsewhere in the header — for instance, in the AutoSEO theme, the breadcrumb-looking line above the logo is actually the <h1> headline, determined in header.php using conditionals based on what page it is. You don’t have to query any more variables, just stick in your echo.

    Now… back to your author.php page…

    ***the following goes in author.php***

    You have to put this in the author.php page again, I’d recommend after the get_header call:

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

    After that, to display the author’s name or whatever, use this:
    <?php echo $curauth->display_name; ?>

    Hope that helps!

Viewing 6 replies - 61 through 66 (of 66 total)
  • The topic ‘Current Author’ is closed to new replies.