Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Why doesn't wp_title() display the author's name on an author archive as it does for a category or date archive? How can I hack this functionality?

header.php calls:

<title><?php wp_title ( '|', true,'right' ); ?></title>

Here is my author.php:

<?php get_header(); ?>
<?php   
    $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    get_userdata(intval($author));
    function validate_gravatar($email) {
    // Craft a potential url and test its headers
    $hash = md5($email);
    $uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
    $headers = @get_headers($uri);
    if (!preg_match("|200|", $headers[0])) {
        $has_valid_avatar = FALSE;
    } else {
        $has_valid_avatar = TRUE;
    }
    return $has_valid_avatar;
}
$user_email = $curauth->user_email;
$has_avatar = validate_gravatar($user_email);
?>


  <div class="content-title">About <?php echo $curauth->display_name; ?></div>

  <div id="curauth" class="post-content">
  <div id="avatar"><?php if($has_avatar) {echo get_avatar($curauth->ID, 70);} ?></div>
  <?php if ($curauth->user_description) : ?>
   <p><?php echo $curauth->user_description; ?></p>
   <?php endif; 
   if ($curauth->user_url) : ?>
   <p><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></p>
   <?php endif; ?>
   <?php if (!$curauth->user_description && !$curauth->user_url) : ?>
   <p>A riddle wrapped in a mystery inside an enigma...</p>
   <?php endif; ?>
  </div>

  <div class="content-title">Contact</div>
  <div id="curauth" class="post-content">
  <?php echo do_shortcode( '[contact-form 1 "Contact Author"]' ); ?>
  </div>


<div class="content-title">
  <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
  <?php _e('Author Archive'); ?>
  <a href="javascript: void(0);" id="mode"<?php if ($_COOKIE['mode'] == 'grid') echo ' class="flip"'; ?>></a> </div>
<ul>
<!-- The Loop -->
<?php get_template_part('loop'); ?>
<?php get_template_part('pagination'); ?>
<?php get_footer(); ?>
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

I see my name in the title when viewing author pages.

wp_title() runs this code during execution..

// If there's an author
if ( is_author() ) {
    $author = get_queried_object();
    $title = $author->display_name;
}

Perhaps your author(s) don't have a display name set?

Additionally be sure to try disabling plugins that may be hooking a filter onto wp_title and check your theme's function file for functions that hook on to...

share|improve this answer
    
Nope they all do. For example: mbird.com/author/sysadmin - Its displaying the name of my blog again. –  two7s_clash Apr 12 '11 at 12:50
    
Tried with plugins disabled? Alot of SEO related plugins like to hook onto wp_title and change things.. –  t31os Apr 12 '11 at 13:19
    
.. or under another theme(to rule out a theme specific function being at fault)... –  t31os Apr 12 '11 at 13:31
    
Nothing hooks into wp_title(). If you navigate around the site, you can see the function working well on other pages. –  two7s_clash Apr 12 '11 at 18:50
    
Does switching theme resolve the problem? Not suggesting it as a solution, just a means to narrow down the problem. –  t31os Apr 12 '11 at 22:51
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.