Skip to content

Instantly share code, notes, and snippets.

@mjangda
Created April 22, 2011 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjangda/936682 to your computer and use it in GitHub Desktop.
Save mjangda/936682 to your computer and use it in GitHub Desktop.
Fix for 2.1.1 with wrong author info being pulled on author pages
<?php
/**
* Fix for author info not properly displaying on author pages
*
* On an author archive, if the first story has coauthors and
* the first author is NOT the same as the author for the archive,
* the query_var is changed.
*
*/
function coa_fix_author_page( &$post ) {
if( is_author() ) {
global $wp_query, $authordata;
// Get the id of the author whose page we're on
$author_id = $wp_query->get( 'author' );
// Check that the the author matches the first author of the first post
if( $author_id != $authordata->ID ) {
// The IDs don't match, so we need to force the $authordata to the one we want
$authordata = get_userdata( $author_id );
}
}
}
// Fix for author info not properly displaying on author pages
add_action( 'the_post', 'coa_fix_author_page' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment