May 30, 2009

Display the Author Who Edited a Post Last

default-avatar-thumb-thumb6599242Want to display the author who last edited any given post? Well, here’s some simple code you can use to have that show on all of your posts.

To first create the function for the task that we are going to do, copy and paste the following code into your theme’s functions.php file:

if (!function_exists('get_the_modified_author')) {
  function get_the_modified_author() {
    global $post;
    if ( $last_id = get_post_meta($post->ID, '_edit_last', true) ) {
      $last_user = get_userdata($last_id);
      return apply_filters('the_modified_author', $last_user->display_name);
    }
  }
}

if (!function_exists('the_modified_author')) {
  function the_modified_author() {
    echo get_the_modified_author();
  }
}

If you know what all of that mumbo-jumbo (php) means, then you should know that it’s as simple as pasting:

<?php the_modified_author(); ?>

anywhere you want for the modified author of any given post. Just make sure that you put that code within you’re WordPress theme’s loop somewhere.


Previous Post and Next Post


Try HostGator Webhosting for 1 cent for the 1st Month Click here and enter "wordpress"

Leave a reply

* means field is required.

*

*