只显示来自登录用户的帖子的Wordpress评论

问题描述:

我尝试获取当前登录用户对当前帖子的所有评论(以及管理员对此评论的回答)。其他用户应该无法看到来自其他用户的评论,但管理员的*评论除外。只显示来自登录用户的帖子的Wordpress评论

     $args =array (
            'status'   => 'approve', 
            'type'   => 'comment', 
            // 'post_author' => get_current_user_id(), 
            'post_status' => 'publish', 
            'post_type'  => 'post', 
            'user_id'  => get_current_user_id(), 
            'number'   => 20, 
            'offset'   => 0, 
            'order'   => 'DESC', 
            'orderby'  => 'comment_date', 
            'count'   => true, 
           ); 
         $comments = get_comments($args); 

         // Referer to http://codex.wordpress.org/Function_Reference/wp_list_comments 
         $list_args = array(
         'reverse_top_level' => false // Show the latest comments at the top of the list 
         ); 
         wp_list_comments($list_args, $comments); 

这不行,我什么也没得到。您是否知道如何在帖子之间的用户之间进行“私密”评论?

https://developer.wordpress.org/reference/functions/is_user_logged_in/ - 阅读本 <?php if(is_user_logged_in()){ ?> your code <?php } else { ?> your code <?php } ?>

+0

我不想要的功能:显示注释仅当用户登录! - 我想显示来自logged_in用户的评论! =>您只能看到自己发表的评论以及管理员对您评论的回复。 – Suisse