Skip to content

Instantly share code, notes, and snippets.

@patilvikasj
Created October 23, 2019 12:26
Show Gist options
  • Select an option

  • Save patilvikasj/4331bf61656a0a6fbac48079c5e5accf to your computer and use it in GitHub Desktop.

Select an option

Save patilvikasj/4331bf61656a0a6fbac48079c5e5accf to your computer and use it in GitHub Desktop.
This function will display author name, bio and Gravtar when author has no posts.
<?php // do not include this line in functions.php
add_filter( 'the_author', function( $name ) {
$author = get_user_by( 'slug', get_query_var( 'author_name' ) );
return $author->display_name;
} );
add_filter( 'get_the_author_description', function( $value, $user_id, $original_user_id ) {
$author = get_user_by( 'slug', get_query_var( 'author_name' ) );
return $author->description;
}, 10, 3 );
add_filter( 'get_the_author_user_email', function( $value, $user_id, $original_user_id ) {
$author = get_user_by( 'slug', get_query_var( 'author_name' ) );
return $author->user_email;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment