How to Rewrite Guest Author Name with Custom Fields in WordPress

Interactive Online > Blog  > CMS  > WordPress  > How to Rewrite Guest Author Name with Custom Fields in WordPress

How to Rewrite Guest Author Name with Custom Fields in WordPress

The trick we are sharing in this article will allow you to show guest author’s name by simply entering a custom field in your post.

How to Rewrite Guest Author Name with Custom Fields in WordPress is a post from: WPBeginner which is not allowed to be copied on other sites.

Related posts:

  1. Embed Custom CSS in Your Single Posts with Custom Fields
  2. How to Add a Digg Button in your WordPress using Custom Fields
  3. How to Add a Custom Author Profile Page to Your WordPress


Have you ever had a guest post on your blog? How do you go about giving the author full credit? We have seen many sites where they add an author profile box either above the post or below the post. But even with the guest author box, the author name field would still show the site author. Some bloggers create entire new author profiles for their guest authors in order to display the right name. We think that it is pointless to create extra user profiles if you know that this guest author will only post once.

The trick we are sharing in this article will allow you to show guest author’s name by simply entering a custom field in your post.

Open your functions.php file and paste the codes below:

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;
}

Now every time that you are posting a guest post, just make sure that you add a custom field called guest-author and it will replace the author’s name with the text that you put in that custom field.

Example:

Rewrite Guest Author's Name using Custom Fields in WordPress

How to Rewrite Guest Author Name with Custom Fields in WordPress is a post from: WPBeginner which is not allowed to be copied on other sites.

Related posts:

  1. Embed Custom CSS in Your Single Posts with Custom Fields
  2. How to Add a Digg Button in your WordPress using Custom Fields
  3. How to Add a Custom Author Profile Page to Your WordPress

(read full article on source site)
Free Website for Your Dental Practice
See why our dental practice websites exceed the features & value of your typcial dentist website.
  • No cookie-cutter websites
  • No duplicate content
  • Custom built with a unique look and feel
  • Unique content written by professional writers
  • Set yourself apart from other dentists
  • The key to your online success!
* we never share your e-mail with third parties.