WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Comment_Query::__construct() public WP 4.2.0

Constructor.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

Sets up the comment query, based on the query vars passed.

{} Это метод класса: WP_Comment_Query{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$WP_Comment_Query = new WP_Comment_Query();
$WP_Comment_Query->__construct( $query );
$query(строка|массив)

Array or query string of comment query parameters.

По умолчанию: ''

  • author_email(строка)
    Comment author email address.
    По умолчанию: ''

  • author_url(строка)
    Comment author URL.
    По умолчанию: ''

  • author__in(int[])
    Array of author IDs to include comments for.
    По умолчанию: ''

  • author__not_in(int[])
    Array of author IDs to exclude comments for.
    По умолчанию: ''

  • comment__in(int[])
    Array of comment IDs to include.
    По умолчанию: ''

  • comment__not_in(int[])
    Array of comment IDs to exclude.
    По умолчанию: ''

  • count(true|false)
    Whether to return a comment count (true) or array of comment objects (false).
    По умолчанию: false

  • date_query(массив)
    Date query clauses to limit comments by. See WP_Date_Query.
    По умолчанию: null

  • fields(строка)
    Comment fields to return. Accepts 'ids' for comment IDs only or empty for all fields.
    По умолчанию: ''

  • ID(int)
    Currently unused.

  • include_unapproved(массив)
    Array of IDs or email addresses of users whose unapproved comments will be returned by the query regardless of $status.
    По умолчанию: ''

  • karma(int)
    Karma score to retrieve matching comments for.
    По умолчанию: ''

  • meta_key(строка)
    Include comments with a matching comment meta key.
    По умолчанию: ''

  • meta_value(строка)
    Include comments with a matching comment meta value. Requires $meta_key to be set.
    По умолчанию: ''

  • meta_query(массив)
    Meta query clauses to limit retrieved comments by. See WP_Meta_Query.
    По умолчанию: ''

  • number(int)
    Maximum number of comments to retrieve.
    По умолчанию: empty (no limit)

  • paged(int)
    When used with $number, defines the page of results to return. When used with $offset, $offset takes precedence.
    По умолчанию: 1

  • offset(int)
    Number of comments to offset the query. Used to build LIMIT clause.

  • no_found_rows(true|false)
    Whether to disable the SQL_CALC_FOUND_ROWS query.
    По умолчанию: true

  • orderby(строка|массив)
    Comment status or array of statuses. To use 'meta_value' or 'meta_value_num', $meta_key must also be defined. To sort by a specific $meta_query clause, use that clause's array key. Accepts 'comment_agent', 'comment_approved', 'comment_author', 'comment_author_email', 'comment_author_IP', 'comment_author_url', 'comment_content', 'comment_date', 'comment_date_gmt', 'comment_ID', 'comment_karma', 'comment_parent', 'comment_post_ID', 'comment_type', 'user_id', 'comment__in', 'meta_value', 'meta_value_num', the value of $meta_key, and the array keys of $meta_query. Also accepts false, an empty array, or 'none' to disable ORDER BY clause.
    По умолчанию: 'comment_date_gmt'

  • order(строка)
    How to order retrieved comments. Accepts 'ASC', 'DESC'.
    По умолчанию: 'DESC'

  • parent(int)
    Parent ID of comment to retrieve children of.
    По умолчанию: ''

  • parent__in(int[])
    Array of parent IDs of comments to retrieve children for.
    По умолчанию: ''

  • parent__not_in(int[])
    Array of parent IDs of comments not to retrieve children for.
    По умолчанию: ''

  • post_author__in(int[])
    Array of author IDs to retrieve comments for.
    По умолчанию: ''

  • post_author__not_in(int[])
    Array of author IDs not to retrieve comments for.
    По умолчанию: ''

  • post_ID(int)
    Currently unused.

  • post_id(int)
    Limit results to those affiliated with a given post ID.

  • post__in(int[])
    Array of post IDs to include affiliated comments for.
    По умолчанию: ''

  • post__not_in(int[])
    Array of post IDs to exclude affiliated comments for.
    По умолчанию: ''

  • post_author(int)
    Post author ID to limit results by.
    По умолчанию: ''

  • post_status(строка|массив)
    Post status or array of post statuses to retrieve affiliated comments for. Pass 'any' to match any value.
    По умолчанию: ''

  • post_type(строка)
    Post type or array of post types to retrieve affiliated comments for. Pass 'any' to match any value.
    По умолчанию: ''

  • post_name(строка)
    Post name to retrieve affiliated comments for.
    По умолчанию: ''

  • post_parent(int)
    Post parent ID to retrieve affiliated comments for.
    По умолчанию: ''

  • search(строка)
    Search term(s) to retrieve matching comments for.
    По умолчанию: ''

  • status(строка|массив)
    Comment statuses to limit results by. Accepts an array or space/comma-separated list of 'hold' (comment_status=0), 'approve' (comment_status=1), 'all', or a custom comment status.
    По умолчанию: 'all'

  • type(строка|массив)
    Include comments of a given type, or array of types. Accepts 'comment', 'pings' (includes 'pingback' and 'trackback'), or any custom type string.
    По умолчанию: ''

  • type__in(string[])
    Include comments from a given array of comment types.
    По умолчанию: ''

  • type__not_in(string[])
    Exclude comments from a given array of comment types.
    По умолчанию: ''

  • user_id(int)
    Include comments for a specific user ID.
    По умолчанию: ''

  • hierarchical(true|false|строка)
    Whether to include comment descendants in the results.

    • 'threaded' returns a tree, with each comment's children stored in a children property on the WP_Comment object.
    • 'flat' returns a flat array of found comments plus their children.
    • Boolean false leaves out descendants. The parameter is ignored (forced to false) when $fields is 'ids' or 'counts'. Accepts 'threaded', 'flat', or false.

    По умолчанию: false

  • cache_domain(строка)
    Unique cache key to be produced when this query is stored in an object cache.
    По умолчанию: 'core'

  • update_comment_meta_cache(true|false)
    Whether to prime the metadata cache for found comments.
    По умолчанию: true

  • update_comment_post_cache(true|false)
    Whether to prime the cache for comment posts.
    По умолчанию: false

Список изменений

С версии 4.2.0 Введена.
С версии 4.4.0 $parent__in and $parent__not_in were added.
С версии 4.4.0 Order by comment__in was added. $update_comment_meta_cache, $no_found_rows, $hierarchical, and $update_comment_post_cache were added.
С версии 4.5.0 Introduced the $author_url argument.
С версии 4.6.0 Introduced the $cache_domain argument.
С версии 4.9.0 Introduced the $paged argument.

Код WP_Comment_Query::__construct() WP 5.8.2

public function __construct( $query = '' ) {
	$this->query_var_defaults = array(
		'author_email'              => '',
		'author_url'                => '',
		'author__in'                => '',
		'author__not_in'            => '',
		'include_unapproved'        => '',
		'fields'                    => '',
		'ID'                        => '',
		'comment__in'               => '',
		'comment__not_in'           => '',
		'karma'                     => '',
		'number'                    => '',
		'offset'                    => '',
		'no_found_rows'             => true,
		'orderby'                   => '',
		'order'                     => 'DESC',
		'paged'                     => 1,
		'parent'                    => '',
		'parent__in'                => '',
		'parent__not_in'            => '',
		'post_author__in'           => '',
		'post_author__not_in'       => '',
		'post_ID'                   => '',
		'post_id'                   => 0,
		'post__in'                  => '',
		'post__not_in'              => '',
		'post_author'               => '',
		'post_name'                 => '',
		'post_parent'               => '',
		'post_status'               => '',
		'post_type'                 => '',
		'status'                    => 'all',
		'type'                      => '',
		'type__in'                  => '',
		'type__not_in'              => '',
		'user_id'                   => '',
		'search'                    => '',
		'count'                     => false,
		'meta_key'                  => '',
		'meta_value'                => '',
		'meta_query'                => '',
		'date_query'                => null, // See WP_Date_Query.
		'hierarchical'              => false,
		'cache_domain'              => 'core',
		'update_comment_meta_cache' => true,
		'update_comment_post_cache' => false,
	);

	if ( ! empty( $query ) ) {
		$this->query( $query );
	}
}