diff --git a/archive.php b/archive.php index b1d91d8e..8ac4a796 100644 --- a/archive.php +++ b/archive.php @@ -24,16 +24,7 @@ get_header(); ?> single_tag_title(); elseif ( is_author() ) : - /* Queue the first post, that way we know - * what author we're dealing with (if that is the case). - */ - the_post(); printf( __( 'Author: %s', '_s' ), '' . get_the_author() . '' ); - /* Since we called the_post() above, we need to - * rewind the loop back to the beginning that way - * we can run the loop properly, in full. - */ - rewind_posts(); elseif ( is_day() ) : printf( __( 'Day: %s', '_s' ), '' . get_the_date() . '' ); diff --git a/inc/extras.php b/inc/extras.php index 66b1d724..31637afe 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -66,3 +66,24 @@ function _s_wp_title( $title, $sep ) { return $title; } add_filter( 'wp_title', '_s_wp_title', 10, 2 ); + +/** + * Sets the authordata global when viewing an author archive. + * + * This provides backwards compatibility with + * http://core.trac.wordpress.org/changeset/25574 + * + * It removes the need to call the_post() and rewind_posts() in an author + * template to print information about the author. + * + * @global WP_Query $wp_query WordPress Query object. + * @return void + */ +function _s_setup_author() { + global $wp_query; + + if ( $wp_query->is_author() && isset( $wp_query->post ) ) { + $GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author ); + } +} +add_action( 'wp', '_s_setup_author' );