Home / Author Bio After Post
Duplicate Snippet

Embed Snippet on Your Site

Author Bio After Post

Display the author bio (if any) after the post content.

<10
Code Preview
php
<?php
global $post;
$author_id = $post->post_author;
// Get author's display name and biographical info
$author_name = get_the_author_meta( 'display_name', $author_id );
$author_bio  = get_the_author_meta( 'description', $author_id );
// Get author's avatar
$author_avatar = get_avatar( $author_id, 96 );
// Only display if author bio is not empty
if ( ! empty( $author_bio ) ) {
	$bio_content = '<div class="author-bio">';
	$bio_content .= '<div class="author-avatar">' . $author_avatar . '</div>';
	$bio_content .= '<div class="author-info">';
	$bio_content .= '<h4>' . esc_html( $author_name ) . '</h4>';
	$bio_content .= '<p>' . wp_kses_post( $author_bio ) . '</p>';
	$bio_content .= '</div>';
	$bio_content .= '</div>';
	// Output bio.
	echo $bio_content;
}

Comments

Add a Comment