Skip to content

Instantly share code, notes, and snippets.

@pcfreak30
Created June 1, 2016 21:03
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 pcfreak30/cb42eebc8c47f0f7d09889dbbcdb38d7 to your computer and use it in GitHub Desktop.
Save pcfreak30/cb42eebc8c47f0f7d09889dbbcdb38d7 to your computer and use it in GitHub Desktop.
function dwqa_the_author( $display_name ) {
global $post;
if ( empty( $post ) ) {
return $display_name;
}
if ( 'dwqa-answer' == $post->post_type || 'dwqa-question' == $post->post_type) {
if ( dwqa_is_anonymous( $post->ID ) ) {
$anonymous_name = get_post_meta( $post->ID, '_dwqa_anonymous_name', true );
$display_name = $anonymous_name ? $anonymous_name : __( 'Anonymous', 'dwqa' );
}
}
return $display_name;
}
add_filter( 'the_author', 'dwqa_the_author' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment