WP_Query::parse_query() – Parse a query string and set query type booleans.
You appear to be a bot. Output may be restricted
Description
Parse a query string and set query type booleans.
Usage
WP_Query::parse_query( $query );
Parameters
- $query
- ( string|array ) optional – { Optional. Array or string of Query parameters.
- $attachment_id
- ( int ) optional – Attachment post ID. Used for 'attachment' post_type.
- $author
- ( int|string ) optional – Author ID, or comma-separated list of IDs.
- $author_name
- ( string ) optional – User 'user_nicename'.
- $author__in
- ( int[] ) optional – An array of author IDs to query from.
- $author__not_in
- ( int[] ) optional – An array of author IDs not to query from.
- $cache_results
- ( bool ) optional – Whether to cache post information. Default true.
- $cat
- ( int|string ) optional – Category ID or comma-separated list of IDs (this or any children).
- $category__and
- ( int[] ) optional – An array of category IDs (AND in).
- $category__in
- ( int[] ) optional – An array of category IDs (OR in, no children).
- $category__not_in
- ( int[] ) optional – An array of category IDs (NOT in).
- $category_name
- ( string ) optional – Use category slug (not name, this or any children).
- $comment_count
- ( array|int ) optional – Filter results by comment count. Provide an integer to match comment count exactly. Provide an array with integer 'value' and 'compare' operator ('=', '!=', '>', '>=', '<', '<=' ) to compare against comment_count in a specific way.
- $comment_status
- ( string ) optional – Comment status.
- $comments_per_page
- ( int ) optional – The number of comments to return per page. Default 'comments_per_page' option.
- $date_query
- ( array ) optional – An associative array of WP_Date_Query arguments. See WP_Date_Query::__construct().
- $day
- ( int ) optional – Day of the month. Default empty. Accepts numbers 1-31.
- $exact
- ( bool ) optional – Whether to search by exact keyword. Default false.
- $fields
- ( string ) optional – Post fields to query for. Accepts:
- '' Returns an array of complete post objects (`WP_Post[]`).
- 'ids' Returns an array of post IDs (`int[]`).
- 'id=>parent' Returns an associative array of parent post IDs,
keyed by post ID (`int[]`). Default ''.
- $hour
- ( int ) optional – Hour of the day. Default empty. Accepts numbers 0-23.
- $ignore_sticky_posts
- ( int|bool ) optional – Whether to ignore sticky posts or not. Setting this to false excludes stickies from 'post__in'. Accepts 1|true, 0|false. Default false.
- $m
- ( int ) optional – Combination YearMonth. Accepts any four-digit year and month numbers 01-12. Default empty.
- $meta_key
- ( string|string[] ) optional – Meta key or keys to filter by.
- $meta_value
- ( string|string[] ) optional – Meta value or values to filter by.
- $meta_compare
- ( string ) optional – MySQL operator used for comparing the meta value. See WP_Meta_Query::__construct() for accepted values and default value.
- $meta_compare_key
- ( string ) optional – MySQL operator used for comparing the meta key. See WP_Meta_Query::__construct() for accepted values and default value.
- $meta_type
- ( string ) optional – MySQL data type that the meta_value column will be CAST to for comparisons. See WP_Meta_Query::__construct() for accepted values and default value.
- $meta_type_key
- ( string ) optional – MySQL data type that the meta_key column will be CAST to for comparisons. See WP_Meta_Query::__construct() for accepted values and default value.
- $meta_query
- ( array ) optional – An associative array of WP_Meta_Query arguments. See WP_Meta_Query::__construct() for accepted values.
- $menu_order
- ( int ) optional – The menu order of the posts.
- $minute
- ( int ) optional – Minute of the hour. Default empty. Accepts numbers 0-59.
- $monthnum
- ( int ) optional – The two-digit month. Default empty. Accepts numbers 1-12.
- $name
- ( string ) optional – Post slug.
- $nopaging
- ( bool ) optional – Show all posts (true) or paginate (false). Default false.
- $no_found_rows
- ( bool ) optional – Whether to skip counting the total rows found. Enabling can improve performance. Default false.
- $offset
- ( int ) optional – The number of posts to offset before retrieval.
- $order
- ( string ) optional – Designates ascending or descending order of posts. Default 'DESC'. Accepts 'ASC', 'DESC'.
- $orderby
- ( string|array ) optional – Sort retrieved posts by parameter. One or more options may be passed. To use 'meta_value', or 'meta_value_num', 'meta_key=keyname' must be also be defined. To sort by a specific
$meta_query
clause, use that clause's array key. Accepts:- 'none'
- 'name'
- 'author'
- 'date'
- 'title'
- 'modified'
- 'menu_order'
- 'parent'
- 'ID'
- 'rand'
- 'relevance'
- 'RAND(x)' (where 'x' is an integer seed value)
- 'comment_count'
- 'meta_value'
- 'meta_value_num'
- 'post__in'
- 'post_name__in'
- 'post_parent__in'
- The array keys of `$meta_query`.
Default is 'date', except when a search is being performed, when the default is 'relevance'.
- $p
- ( int ) optional – Post ID.
- $page
- ( int ) optional – Show the number of posts that would show up on page X of a static front page.
- $paged
- ( int ) optional – The number of the current page.
- $page_id
- ( int ) optional – Page ID.
- $pagename
- ( string ) optional – Page slug.
- $perm
- ( string ) optional – Show posts if user has the appropriate capability.
- $ping_status
- ( string ) optional – Ping status.
- $post__in
- ( int[] ) optional – An array of post IDs to retrieve, sticky posts will be included.
- $post__not_in
- ( int[] ) optional – An array of post IDs not to retrieve. Note: a string of comma- separated IDs will NOT work.
- $post_mime_type
- ( string ) optional – The mime type of the post. Used for 'attachment' post_type.
- $post_name__in
- ( string[] ) optional – An array of post slugs that results must match.
- $post_parent
- ( int ) optional – Page ID to retrieve child pages for. Use 0 to only retrieve top-level pages.
- $post_parent__in
- ( int[] ) optional – An array containing parent page IDs to query child pages from.
- $post_parent__not_in
- ( int[] ) optional – An array containing parent page IDs not to query child pages from.
- $post_type
- ( string|string[] ) optional – A post type slug (string) or array of post type slugs. Default 'any' if using 'tax_query'.
- $post_status
- ( string|string[] ) optional – A post status (string) or array of post statuses.
- $posts_per_page
- ( int ) optional – The number of posts to query for. Use -1 to request all posts.
- $posts_per_archive_page
- ( int ) optional – The number of posts to query for by archive page. Overrides 'posts_per_page' when is_archive(), or is_search() are true.
- $s
- ( string ) optional – Search keyword(s). Prepending a term with a hyphen will exclude posts matching that term. Eg, 'pillow -sofa' will return posts containing 'pillow' but not 'sofa'. The character used for exclusion can be modified using the the 'wp_query_search_exclusion_prefix' filter.
- $second
- ( int ) optional – Second of the minute. Default empty. Accepts numbers 0-59.
- $sentence
- ( bool ) optional – Whether to search by phrase. Default false.
- $suppress_filters
- ( bool ) optional – Whether to suppress filters. Default false.
- $tag
- ( string ) optional – Tag slug. Comma-separated (either), Plus-separated (all).
- $tag__and
- ( int[] ) optional – An array of tag IDs (AND in).
- $tag__in
- ( int[] ) optional – An array of tag IDs (OR in).
- $tag__not_in
- ( int[] ) optional – An array of tag IDs (NOT in).
- $tag_id
- ( int ) optional – Tag id or comma-separated list of IDs.
- $tag_slug__and
- ( string[] ) optional – An array of tag slugs (AND in).
- $tag_slug__in
- ( string[] ) optional – An array of tag slugs (OR in). unless 'ignore_sticky_posts' is true. Note: a string of comma-separated IDs will NOT work.
- $tax_query
- ( array ) optional – An associative array of WP_Tax_Query arguments. See WP_Tax_Query::__construct().
- $title
- ( string ) optional – Post title.
- $update_post_meta_cache
- ( bool ) optional – Whether to update the post meta cache. Default true.
- $update_post_term_cache
- ( bool ) optional – Whether to update the post term cache. Default true.
- $update_menu_item_cache
- ( bool ) optional – Whether to update the menu item cache. Default false.
- $lazy_load_term_meta
- ( bool ) optional – Whether to lazy-load term meta. Setting to false will disable cache priming for term meta, so that each get_term_meta() call will hit the database. Defaults to the value of `$update_post_term_cache`.
- $w
- ( int ) optional – The week number of the year. Default empty. Accepts numbers 0-53.
- $year
- ( int ) optional – The four-digit year. Default empty. Accepts any four-digit year. }
Returns
void
Source
File name: wordpress/wp-includes/class-wp-query.php
Lines:
101 to 200 of 351
if ( '' !== $qv['minute'] ) { $this->WP_Query::is_time = true; $this->WP_Query::is_date = true; } if ( '' !== $qv['hour'] ) { $this->WP_Query::is_time = true; $this->WP_Query::is_date = true; } if ( $qv['day'] ) { if ( ! $this->WP_Query::is_date ) { $date = sprintf( '%04d-%02d-%02d', $qv['year'], $qv['monthnum'], $qv['day'] ); if ( $qv['monthnum'] && $qv['year'] && ! wp_checkdate( $qv['monthnum'], $qv['day'], $qv['year'], $date ) ) { $qv['error'] = '404'; } else { $this->WP_Query::is_day = true; $this->WP_Query::is_date = true; } } } if ( $qv['monthnum'] ) { if ( ! $this->WP_Query::is_date ) { if ( 12 < $qv['monthnum'] ) { $qv['error'] = '404'; } else { $this->WP_Query::is_month = true; $this->WP_Query::is_date = true; } } } if ( $qv['year'] ) { if ( ! $this->WP_Query::is_date ) { $this->WP_Query::is_year = true; $this->WP_Query::is_date = true; } } if ( $qv['m'] ) { $this->WP_Query::is_date = true; if ( strlen( $qv['m'] ) > 9 ) { $this->WP_Query::is_time = true; } elseif ( strlen( $qv['m'] ) > 7 ) { $this->WP_Query::is_day = true; } elseif ( strlen( $qv['m'] ) > 5 ) { $this->WP_Query::is_month = true; } else { $this->WP_Query::is_year = true; } } if ( $qv['w'] ) { $this->WP_Query::is_date = true; } $this->query_vars_hash = false; $this->WP_Query::parse_tax_query( $qv ); foreach ( $this->tax_query->queries as $tax_query ) { if ( ! is_array( $tax_query ) ) { continue; } if ( isset( $tax_query['operator'] ) && 'NOT IN' !== $tax_query['operator'] ) { switch ( $tax_query['taxonomy'] ) { case 'category': $this->WP_Query::is_category = true; break; case 'post_tag': $this->WP_Query::is_tag = true; break; default: $this->WP_Query::is_tax = true; } } } unset( $tax_query ); if ( empty( $qv['author'] ) || ( '0' == $qv['author'] ) ) { $this->WP_Query::is_author = false; } else { $this->WP_Query::is_author = true; } if ( '' !== $qv['author_name'] ) { $this->WP_Query::is_author = true; } if ( ! empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) { $post_type_obj = get_post_type_object( $qv['post_type'] ); if ( ! empty( $post_type_obj->has_archive ) ) { $this->WP_Query::is_post_type_archive = true; } } if ( $this->WP_Query::is_post_type_archive || $this->WP_Query::is_date || $this->WP_Query::is_author || $this->WP_Query::is_category || $this->WP_Query::is_tag || $this->WP_Query::is_tax ) { $this->WP_Query::is_archive = true; }