List all posts commented by current user

If we want to avoid any filters and manual SQL queries, we could try (untested):

$args = array(
    'post_type'      => 'foods',
    'posts_per_page' => 5,
    'post__in' => array_unique( 
         wp_list_pluck( 
            get_comments( array(
                'user_id' => get_current_user_id() 
                )
            ),       
            'comment_post_ID' 
         )
    ),
);
$my_query = new WP_Query( $args );

Leave a Comment