So here is the situation, I have a wordpress blog site that is a few years old, and every user had a different account to post with.
Now what i want is a plugin/script that automatically adds the name of each author as a tag or a category.
So for example if 'Andre' was the author of a blogpost made on my site a few years ago, he should be tagged in that blogpost Tags: Andre, another thing tagged before, etc
The solution needs to work for posts previously made.
Thanks!
So here is the situation, I have a wordpress blog site that is a few years old, and every user had a different account to post with.
Now what i want is a plugin/script that automatically adds the name of each author as a tag or a category.
So for example if 'Andre' was the author of a blogpost made on my site a few years ago, he should be tagged in that blogpost Tags: Andre, another thing tagged before, etc
The solution needs to work for posts previously made.
Thanks!
Share Improve this question edited Nov 5, 2018 at 21:03 Johansson 15.4k11 gold badges44 silver badges80 bronze badges asked Nov 5, 2018 at 19:39 RIcky AroraRIcky Arora 11 bronze badge 2- Any particular reason they need to be Tags? Since the post authors are already stored, you could update your theme instead to show the post author, and there is an option to have an author archive where you can see all the posts written by a particular author. – WebElaine Commented Nov 5, 2018 at 20:07
- 1 Hi, so I am moving the blog to another theme where those authors do not exist and a requirement is that we do not recreate these accounts, so we decided tagging to be the way that the admin can make the post but tag the actual authors so users can sort by author. – RIcky Arora Commented Nov 5, 2018 at 20:10
1 Answer
Reset to default 0I would do this by looking into the wp_get_post_revisions
So put this in your functions.php
:
function show_revisions( $revisions ){
echo '<ul>';
foreach( $revisions as $revision ):
// Gets the author if there is one.
// Prints (??) if there isn't one.
$author = empty( ucfirst( get_the_author_meta( 'display_name', $post_author ) ) ) ? '(??)' : ucfirst( get_the_author_meta( 'display_name', $revision->post_author ) );
echo '<li>';
echo '<p>Author:' . $author . '</p>';
echo '</li>';
endforeach;
echo '</ul>';
}
And put this in your single.php
and/or page.php
and/or whereever you want the list of authors to be shown:
$revisions = wp_get_post_revisions();
show_revisions( $revisions );