How to Add Different Author Description in Author box

8
544

Few days back I got a comment on my post for the best guest post system, it was Sajith from techblaster.net, who was looking for a system to add different author description in Author box for the same author.

He thought that I have it on my blog, so wanted to check how I have done it. Unfortunately I was not having that system at that time but I replied saying that I will look into once I will get some time.

Now I have something which can be used to show different author description, I have developed a manual system to achieve that functionality.

I have already tested this code on Thesis as I am using it on my blog.

To get this function you need to add below function to your custom_functions.php file:

function author_description() {
global $post;
$source = get_post_meta($post->ID, 'author_desc', true);
  if ($source) {
    return $source; }
  else {
    return the_author_description(); }
}

The above function will return author description based on the post meta field, if there is no post meta data than it will pick it from user profile field.

You need to change the code for your author box also, below is a reference code taken from DIYThemes blog.

You need to replace the call to the_author_description() to author_description().

function thesis_author_box() {
    if (is_single()) {
        ?>
        <div class="author_info">
        <h4>This post was written by...</h4>
        <span class="author_photo"><?php echo get_avatar( get_the_author_id() , 96 ); ?></span>
        <p><?php the_author_posts_link(); ?> &ndash; who has written <?php the_author_posts(); ?> posts on <a href="<?php bloginfo('home'); ?>"><?php bloginfo('name'); ?></a>.</p>
        <p><?php echo author_description() ?></p>
        <p class="author_email"><a href="mailto:<?php the_author_email(); ?>" title="Send an Email to the Author of this Post">Contact the author</a></p>
        </div>
    <?php }
}

add_action('thesis_hook_after_post','thesis_author_box');

To use this code you need to add a custom field to your post. If you want to use a different description rather than author’s profile description, than add a custom field “author_desc” with the description for that post.

Post meta for Different Author Discription
Post meta for Different Author Discription

For the first time you need to click on enter new and add a field name as “author_desc”, after that you can select it from the drop down and enter the description.

If you want to use the Author’s profile field than just do not enter this custom field and it will show the profile description.

You can use the above code to add the same functionality to your blog and it can be helpful in case you accept guest post in text format. You can add these different author description to your author box without having to create an user account on your blog.

Let me know through comments, if you find it useful at your blog.

8 COMMENTS

  1. Yes, this is useful to work easily and add author description. I like your concept of Author box with custom field option. Many blogger need to add different description so it will help to add their own information as they wish.

    • Yes, I have seen many blog which adds description at the end of the post, even after having author box. This custom field will benefit them..

  2. Hi.. I wasn’t aware that this can be possible.. Anyway, thanks for the help here.. You are so generous in giving such information..

  3. Thanks for the step by step instruction on how to add different author on the author box.. This is a big help for me and for all the readers who need this..

Comments are closed.