admin管理员组文章数量:1130349
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 );
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 );
本文标签: usersHow do I tag every author in their posts that they have made previously
版权声明:本文标题:users - How do I tag every author in their posts that they have made previously 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749198532a2331402.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论