首页    >    新闻资讯    >   在WordPress中显示文章最后一次修改的作者

在WordPress中显示文章最后一次修改的作者

WordPress2.8添加了一个新的模板标签——the_modified_author(),允许你显示文章最后一次修改的作者。这对于多人合写的博客是一件很有用的功能。

实现这个功能很简单,在functions.php中添加:

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();
  }
}

完成后,只要在日志里添加如下代码就可以显示最后修改的作者了:

<?php the_modified_author(); ?>

原文:How to: Display the latest author who modified a post

分类:新闻资讯

标签:, ,

* 版权声明:作者WordPress啦! 转载请注明出处。