Add Author Bio on Author Archive Pages

This is a Developer Level doc.

If you're unfamiliar with PHP and/or editing files, codes and templates, as well as with resolving possible conflict, please seek help from a professional. Under our Support Policy, we don't provide support for modifications and customization.

If you wish to display author bio(graphy) on author archive pages, use the following PHP snippet:

<?php

function my_author_bio() {

// Get author data.
$author = get_the_author();
$description = get_the_author_meta( 'description' );
$url = esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) );

// Only display if author has a description (optional).
if ( ! $description ) {
return;
}

if ( is_archive( $author ) ) {
?>

<section id="author-bio">

<div id="author-bio-inner">

<div>

<a href="<?php echo esc_url( $url ); ?>" title="<?php esc_attr_e( 'Visit Author Page', 'oceanwp' ); ?>" rel="author" >
<?php
// Display author avatar.
echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'ocean_author_bio_avatar_size', 100 ) ); ?>
</a>

</div><!-- .author-bio-avatar -->

<div>

<h4>
<a href="<?php echo esc_url( $url ); ?>" title="<?php esc_attr_e( 'Visit Author Page', 'oceanwp' ); ?>">
<?php echo esc_html( strip_tags( $author ) ); ?>
</a>
</h4><!-- .author-bio-title -->

<?php
// Outputs the author description if one exists.
if ( $description ) : ?>

<div>
<?php echo wp_kses_post( $description ); ?>
</div><!-- author-bio-description -->

<?php endif; ?>

</div>

</div><!-- #author-bio-inner -->

</section><!-- #author-bio -->

<?php
}
}

add_filter( 'ocean_before_content', 'my_author_bio' );

All PHP snippets should be added via a child theme's functions.php file.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.