How to Add Two Aurthor Names for a Blog Post in WordPress

If you own a blog that has multiple authors. And sometimes more than one author works in a blog post.

And both the authors deserve their names on the blog post. But the WordPress allows only one name to be added to the blog posts.

So, in such cases, where the posts are contributed by two authors. Blog owners usually add a su_note in italics like this.

GuestContribution

This post has been contributed by Asif Ahmed & Ahmed Asif. 

While this works for many, and there is technical knowledge required, you might want to know the trick where you can add the names of both authors which look like this.

How to add two names as author of a blog post

This can be achieved without the use of any plugin. You just need to add this code in the functions.php file of your theme.

function guest_author_name( $name ) {
global $post;

$author = get_post_meta( $post->ID, ‘guest-author’, true );

if ( $author )
$name = $author;

 

return $name;
}

You can find the functions.php by going to Appearance – Editor. Open functions.php and paste the code at the end. Like this.

GuestContribution01

After adding the code. All you need to do is add this custom code to the post where you want to add both the names.

GuestContribution02

If the Custom Feild is not visible below the post editor, you can make it visible from the Screen Options (found on top right)

GuestContribution03

Hope you find this useful.

[su_note]Pro tip: Create a sperate account in your blog and name it something like ‘guest, contributor’, ‘team’ etc and use it every time you want to add two names to a post, or just guest contributions from different people who will publish every once in a while. Because creating a dedicated account for them won’t make much sense. [/su_note]

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

NO COMMENTS

LEAVE A REPLY