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.
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.
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.
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.
If the Custom Feild is not visible below the post editor, you can make it visible from the Screen Options (found on top right)
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]