Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronjonesweb/4dd2db7deb47ca075a94145450dd199f to your computer and use it in GitHub Desktop.
Save cameronjonesweb/4dd2db7deb47ca075a94145450dd199f to your computer and use it in GitHub Desktop.
Fixes an issue with WordPress where the current author is empty on author archives with no posts
<?php
add_action( 'template_redirect', 'cameronjonesweb_fix_author_no_posts' );
function cameronjonesweb_fix_author_no_posts() {
global $authordata;
if( is_author() && empty( $authordata ) ) {
$authordata = get_queried_object();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment