本文实例讲述了WordPress后台显示相关用户文章相关联评论的方法。分享给大家供大家参考。具体分析如下:
将下面的代码添加到当前主题的 functions.php 文件即可,代码如下:
复制代码 代码如下://后台只显示当前用户文章关联的评论function wpdx_get_comment_list_by_user($clauses) {if (is_admin()) {global $user_ID, $wpdb;$clauses['join'] = ", wp_posts";$clauses['where'] .= " AND wp_posts.post_author = ".$user_ID." AND wp_comments.comment_post_ID = wp_posts.ID";};return $clauses;};if(!current_user_Can('edit_oThers_posts')) {add_filter('comments_clauses', 'wpdx_get_comment_list_by_user');}
注:如果你的WordPress所使用的数据库前缀不是默认的 wp_,请将第 5 、6 行中的 wp_ 修改为你的WordPress站点的数据库前缀.
希望本文所述对大家的wordpress建站有所帮助。














发表评论