General Comments Post User Search Order Pagination Custom Fields Total Count Overview Use this tool to create custom code for WordPress Comment Query with WP_Comment_Query class. Usage Fill in the user-friendly form. Click the “Update Code” button. Copy the code to your project. Or save it as a snippet and share with the community. Examples If you are still learning how to use this tool, check out the following examples: All comment by specific email All unapproved comments Last 10 approved comments on Review post type Query Variable Name The variable used in the code. Show The Loop Yes No Show the comments loop. Comment ID Show comment by ID. Comment Parent ID Show comments based on comment parent id. Comment Status Choose... Hold Approve Spam Trash Show comments with certain status. Comment Karma Show comments with certain karma. Comment Type Choose... Comment Pingback Trackback Pings (pingback & trackback) Custom Type Show comments with certain type. Custom Comment Type Show comments based on custom type. Post ID Show comments based on certain Post. Post Parent ID Show comments based on post parent id. Post Name Show comments based on post name. Post Author Show comments based on post author. Post Status Show comments based on post status. Post Type Show comments based on post type. User ID Show comments based on certain User. Author Email Show comments based on certain author email. Search Keyword Show comments based on a possible keyword. Order Choose... ASC DESC - Default Ascending or Descending order. Order by Choose... User ID Comment ID Comment Type Comment Approved Comment Parent Comment Date Comment Date GMT Comment Post ID Comment Author Comment Author Email Comment Author IP Comment Author URL Comment Content Comment Agent Comment Karma Sort retrieved comments by. Number Number of comments to show. Offset Number of comments to displace or pass over. Meta Query No save snippets... Select from your saved WP_Meta_Query snippets. Total Count Choose... True False - Default The total count of comments found. Update Code Save Snippet
// WP_Comment_Query arguments $args = array( 'status' => 'approve', 'type' => 'comment', 'post_type' => 'review', 'number' => '10', 'orderby' => 'comment_date', ); // The Comment Query $comment_query = new WP_Comment_Query( $args );