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.

add_filter( 'the_author', 'guest_author_name' );
add_filter( 'get_the_author_display_name', 'guest_author_name' );

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]

Zoom vs Google Meet, Which One is Better for Teaching Online

For the past few years, we have seen something no one has ever witnessed...

How to Improve the Webcam Video Quality for Online Classes / Sessions

Every laptop you get in the market has a bad web camera compared to...

Start Teaching on YouTube – How to Create and Run A Successful YouTube Channel

If you aren’t already aware YouTube is the second biggest search engine after Google....

- A word from our sponsor -

spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.