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:
FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.
FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.
<?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
Tags: