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:
201 to 300 of 351
} if ( '' != $qv['feed'] ) { $this->WP_Query::is_feed = true; } if ( '' != $qv['embed'] ) { $this->WP_Query::is_embed = true; } if ( '' != $qv['tb'] ) { $this->WP_Query::is_trackback = true; } if ( '' != $qv['paged'] && ( (int) $qv['paged'] > 1 ) ) { $this->WP_Query::is_paged = true; } // If we're previewing inside the write screen. if ( '' != $qv['preview'] ) { $this->WP_Query::is_preview = true; } if ( is_admin() ) { $this->is_admin = true; } if ( false !== strpos( $qv['feed'], 'comments-' ) ) { $qv['feed'] = str_replace( 'comments-', '', $qv['feed'] ); $qv['withcomments'] = 1; } $this->WP_Query::is_singular = $this->WP_Query::is_single || $this->WP_Query::is_page || $this->WP_Query::is_attachment; if ( $this->WP_Query::is_feed && ( ! empty( $qv['withcomments'] ) || ( empty( $qv['withoutcomments'] ) && $this->WP_Query::is_singular ) ) ) { $this->WP_Query::is_comment_feed = true; } if ( ! ( $this->WP_Query::is_singular || $this->WP_Query::is_archive || $this->WP_Query::is_search || $this->WP_Query::is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST && $this->WP_Query::is_main_query() ) || $this->WP_Query::is_trackback || $this->WP_Query::is_404 || $this->is_admin || $this->WP_Query::is_robots || $this->is_favicon ) ) { $this->WP_Query::is_home = true; } // Correct `is_*` for 'page_on_front' and 'page_for_posts'. if ( $this->WP_Query::is_home && 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) { $_query = wp_parse_args( $this->WP_Query::query ); // 'pagename' can be set and empty depending on matched rewrite rules. Ignore an empty 'pagename'. if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { unset( $_query['pagename'] ); } unset( $_query['embed'] ); if ( empty( $_query ) || ! array_diff( array_keys( $_query ), array( 'preview', 'page', 'paged', 'cpage' ) ) ) { $this->WP_Query::is_page = true; $this->WP_Query::is_home = false; $qv['page_id'] = get_option( 'page_on_front' ); // Correct <!--nextpage--> for 'page_on_front'. if ( ! empty( $qv['paged'] ) ) { $qv['page'] = $qv['paged']; unset( $qv['paged'] ); } } } if ( '' !== $qv['pagename'] ) { $this->queried_object = get_page_by_path( $qv['pagename'] ); if ( $this->queried_object && 'attachment' === $this->queried_object->post_type ) { if ( preg_match( '/^[^%]*%(?:postname)%/', get_option( 'permalink_structure' ) ) ) { // See if we also have a post with the same slug. $post = get_page_by_path( $qv['pagename'], OBJECT, 'post' ); if ( $post ) { $this->queried_object = $post; $this->WP_Query::is_page = false; $this->WP_Query::is_single = true; } } } if ( ! empty( $this->queried_object ) ) { $this->queried_object_id = (int) $this->queried_object->ID; } else { unset( $this->queried_object ); } if ( 'page' === get_option( 'show_on_front' ) && isset( $this->queried_object_id ) && get_option( 'page_for_posts' ) == $this->queried_object_id ) { $this->WP_Query::is_page = false; $this->WP_Query::is_home = true; $this->is_posts_page = true; } if ( isset( $this->queried_object_id ) && get_option( 'wp_page_for_privacy_policy' ) == $this->queried_object_id ) { $this->WP_Query::is_privacy_policy = true; } } if ( $qv['page_id'] ) { if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == $qv['page_id'] ) {