Custom Author Bio Box

Display a custom author bio box at the end of each post.

<?php
function custom_author_bio() {
    if (is_single() && get_the_author_meta('description')) {
        $author_id = get_the_author_meta('ID');
        $author_name = get_the_author_meta('display_name');
        $author_description = get_the_author_meta('description');
        $author_avatar = get_avatar($author_id);

        echo '<div class="author-bio">';
        echo '<h3>About ' . esc_html($author_name) . '</h3>';
        echo $author_avatar;
        echo '<p>' . esc_html($author_description) . '</p>';
        echo '</div>';
    }
}
add_action('the_content', 'custom_author_bio');

Post Comment