$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>users - How do I tag every author in their posts that they have made previously|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

users - How do I tag every author in their posts that they have made previously

matteradmin8PV0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

I 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 );
Post a comment

comment list (0)

  1. No comments so far