Enable Author Bio Box

Here is some code to enable the author bio box.

Many web sites have an author box at the end of a post. The below code shows how to add the author box to a post page. Here is the result of the below code:



add_action( 'beans_post_after_markup', 'mythemeprefix_add_author_box' );
function mythemeprefix_add_author_box() {
    if ( is_single() ) {
    <div id="author-info" class="uk-panel uk-panel-box author-box">

       <div class="uk-clearfix">

       <?php echo get_avatar( get_the_author_meta( 'user_email' ), '80', $default, $alt, 
array( 'class' => array( 'uk-border-rounded', 'uk-align-medium-left' ) ) ); ?>
       <h3><?php the_author(); ?></h3>
       <p><?php the_author_meta('description'); ?></p>




I added an if is_single condition to only show the author-box on the single posts page. I then added the class author-box and changed uk-border-circle to uk-border-rounded.

The CSS:

.author-box {
background: #cde7ec5e;
border-radius: 10px;
border: 1px solid #a0daa0;

Add a link to the author posts page. Modify:

<h3><?php the_author(); ?></h3>

to become

<h3><?php the_author_posts_link(); ?></h3>

It will turn the Author name into a link. Clicking the link leads to the Author Archives.
To remove the author archive page title add:

beans_remove_action( 'beans_post_archive_title' );




I discovered the code in a forum post
community.getbeans.io/discussion/how-to-enable-author-bio-box/ and then modified it.

Filed under: Learning

No comment yet, add your voice below!

Add a Comment

Your email address will not be published. Required fields are marked *

Comment *
Name *
Email *