How to Enable Author Bio Box


Hi,

How to Add an Author Info Box in WordPress Posts.


Hello @sheyad,

Adding an author box is quite easy. Let me show you a way (not THE way) to do so.

First, you have to build the author info box in itself.

Let's build a very classical author box with :

  • author avatar ;
  • author name ;
  • author bio.

I'll use some Uikit css styles included in Beans v.1.5.

<div id="author-info" class="uk-panel uk-panel-box">

      <div class="uk-clearfix">

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

     </div>

</div>

Secondly, you have to decide where exactly to add this author box in your post. You could add it anywhere : in the sidebar, below the title etc. Here, I'll assume that you want this box to be displayed below the post content.

To do so, you have to find the Beans markup to which this author box will be "attached". In our case, it is the beans_post markup-ID. With Firebug or Chromes Dev Tools, have a look at your site to find this markup. Here is a screenshot.

Now, all you have to do is to add an action that will "hook" your author box in this place. Let's do this in a single.php file.

Note that, by default, the Beans Child theme comes without single.php, you have to create it. Don't forget to add beans_load_document(); at the end. Once single.php is added in your theme folder, add this in single.php :

//* 2-1 Add Author Box.
add_action( 'beans_post_after_markup', 'mythemeprefix_add_author_box' );
function mythemeprefix_add_author_box() {
  ?>
    <--- my author box built in step 1 --->
<?php

You can also add this hook in your functions.php with a little help from conditionnal tags.

Hope it helps !

Happy coding, as @hellofromtonya would say ! πŸ™‚

Mathieu


Working fine!! Thanks Mathieu

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

      <div class="uk-clearfix">

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

     </div>

</div>

<?php
}

Write a reply

Login or register to write a reply, it's free!