May 2017
Beginner to intermediate
536 pages
14h 25m
English
The WP_Comment_Query class works with the wp_comments and wp_commentmeta tables for retrieving WordPress post comments-related data. This class is used in some of the themes to provide custom comments-related features. However, this is less frequently used compared to the WP_Query and the WP_User_Query classes. The following code shows the default usage of this class:
$comments_query = new WP_Comment_Query; $comments = $comments_query->query( $args ); if ( $comments ) { foreach ( $comments as $comment ) { // display commnets } }
You can use this class to retrieve comments from a specific user, specific posts, comments with a certain status, and many other parameters.
Read now
Unlock full access