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

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

0条评论
标签:
更多

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啦! 转载请注明出处。

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.