Remove Author Box In Genesis If ( Bio ) Description Empty

The code in this tutorial enables you to remove the author box from single posts when the users bio is empty.

Based on this question from a member of the Genesis community:

Could anybody please tell me how to hide the author box if the author (user) bio is empty.

Here’s the code for your child themes functions file:

add_action( 'genesis_entry_footer', 'hide_empty_author_box' );

function hide_empty_author_box() {

global $user_ID;

$bio = get_the_author_meta( 'description', $user_ID );

if ( empty( $bio ) ) {

    remove_action( 'genesis_after_post', 'genesis_do_author_box_single' );

    remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
    
    }

}

You can use description or user_description for the 1st parameter in get_the_author_meta.

Here’s another solution which also works :

add_filter( 'get_the_author_genesis_author_box_single', 'remove_author_box_single', 10, 2 );

function remove_author_box_single( $value, $user_id ) {
	
    $field = get_the_author_meta( 'description', $user_id );
	
    if ( $field )
	return true;
}

Source

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.