2017-02-09 57 views
0

我试图显示在Wordpress中创作和编辑页面的人员列表,而不仅仅是编写了修订版本的人员列表。 the_modified_author()给了我最后一次保存页面的人的姓名。 birgire建议使用此代码来获取所有编辑的列表,但它似乎只显示原始文章和所有修订的作者,并且不包括那些保存实际上不是修订的修改的人员的姓名:如何列出一个WordPress页面的所有编辑器,包括那些编辑(保存的页面)而不创建适当修订的编辑器?

function get_the_modified_authors_wpse_99226(){ 
global $wpdb; 
$authors = array(); 
$results = $wpdb->get_results($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE (post_type = '%s' AND ID = %d) OR (post_type = 'revision' AND post_parent = %d) GROUP BY post_author", get_post_type(get_the_ID()), get_the_ID(), get_the_ID())); 
foreach($results as $row){ 
     $authors[] = get_the_author_meta('display_name', $row->post_author); 
} 
return implode(", ", $authors); 
} 

有时人们编辑页面(例如,他们编辑自定义字段)然后更新帖子。发生这种情况时,它们将列在the_modified_author()之下,但不会被视为修订的作者。

我需要的是两个修订版本作者以及那些在不创建修订版的情况下编辑(保存)页面的人员的组合列表。有点像modified_author的函数,但没有'_edit_last', true部分。 这可能吗?

回答

0

请尝试下面的代码:

$revisions = $wpdb->get_results("select * from {$wpdb->posts} where post_parent={$post_id} and post_type='revision'") 

您可能需要根据您的需要做一些改变。

相关问题