How to Rewrite Author Name on Post For a Guest Author

How to Rewrite Author Name on Post For a Guest Author

Ever want to post an article submitted to your blog by someone else?

Here’s an easy way to post it yourself as admin and rewrite the author’s name to whatever you want on a case by case basis.

Add this to your single.php and/or page.php file where you want the author name to show up:

<?php $author = get_post_meta($post->ID, "guest-author", true);
if ($author != "") {
echo $author;
} else {
the_author();
} ?>

Ordinarily, you would just replace this tag with the above code:

<?php the_author_url(); ?>

Now, when you want to add a guest author’s name to the post, simply create a custom field called guest-author and add the name of the author as the value of the field.

Source: WP Recipes

Free Video Why 100 is NOT a Perfect Google PageSpeed Score (*5 Min Watch) Learn how to use Google PageSpeed Insights to set realistic goals, improve site speed, and why aiming for a perfect 100 is the WRONG goal.
Tags: