[ Index ] |
PHP Cross Reference of WordPress |
[Source view] [Print] [Project Stats]
Query API: WP_Query class
File Size: | 4606 lines (141 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
WP_Query:: (67 methods):
init_query_flags()
init()
parse_query_vars()
fill_query_vars()
parse_query()
parse_tax_query()
parse_search()
parse_search_terms()
get_search_stopwords()
parse_search_order()
parse_orderby()
parse_order()
set_404()
get()
set()
get_posts()
set_found_posts()
next_post()
the_post()
have_posts()
rewind_posts()
next_comment()
the_comment()
have_comments()
rewind_comments()
query()
get_queried_object()
get_queried_object_id()
__construct()
__get()
__isset()
__call()
is_archive()
is_post_type_archive()
is_attachment()
is_author()
is_category()
is_tag()
is_tax()
is_comments_popup()
is_date()
is_day()
is_feed()
is_comment_feed()
is_front_page()
is_home()
is_privacy_policy()
is_month()
is_page()
is_paged()
is_preview()
is_robots()
is_favicon()
is_search()
is_single()
is_singular()
is_time()
is_trackback()
is_year()
is_404()
is_embed()
is_main_query()
setup_postdata()
generate_postdata()
reset_postdata()
lazyload_term_meta()
lazyload_comment_meta()
init_query_flags() X-Ref |
Resets query flags to false. The query flags are what page info WordPress was able to figure out. since: 2.0.0 |
init() X-Ref |
Initiates object properties and sets default values. since: 1.5.0 |
parse_query_vars() X-Ref |
Reparse the query vars. since: 1.5.0 |
fill_query_vars( $query_vars ) X-Ref |
Fills in the query variables, which do not exist within the parameter. param: array $query_vars Defined query variables. return: array Complete query variables with undefined ones filled in empty. since: 2.1.0 since: 4.5.0 Removed the `comments_popup` public query variable. |
parse_query( $query = '' ) X-Ref |
Parse a query string and set query type booleans. param: string|array $query { since: 1.5.0 since: 4.2.0 Introduced the ability to order by specific clauses of a `$meta_query`, by passing the clause's since: 4.4.0 Introduced `$post_name__in` and `$title` parameters. `$s` was updated to support excluded since: 4.5.0 Removed the `$comments_popup` parameter. since: 4.6.0 Added 'post_name__in' support for `$orderby`. Introduced the `$lazy_load_term_meta` argument. since: 4.9.0 Introduced the `$comment_count` parameter. since: 5.1.0 Introduced the `$meta_compare_key` parameter. since: 5.3.0 Introduced the `$meta_type_key` parameter. |
parse_tax_query( &$q ) X-Ref |
Parses various taxonomy related query vars. For BC, this method is not marked as protected. See [28987]. param: array $q The query variables. Passed by reference. since: 3.1.0 |
parse_search( &$q ) X-Ref |
Generates SQL for the WHERE clause based on passed search terms. param: array $q Query variables. return: string WHERE clause. since: 3.7.0 |
parse_search_terms( $terms ) X-Ref |
Check if the terms are suitable for searching. Uses an array of stopwords (terms) that are excluded from the separate term matching when searching for posts. The list of English stopwords is the approximate search engines list, and is translatable. param: string[] $terms Array of terms to check. return: string[] Terms that are not stopwords. since: 3.7.0 |
get_search_stopwords() X-Ref |
Retrieve stopwords used when parsing search terms. return: string[] Stopwords. since: 3.7.0 |
parse_search_order( &$q ) X-Ref |
Generates SQL for the ORDER BY condition based on passed search terms. param: array $q Query variables. return: string ORDER BY clause. since: 3.7.0 |
parse_orderby( $orderby ) X-Ref |
Converts the given orderby alias (if allowed) to a properly-prefixed value. param: string $orderby Alias for the field to order by. return: string|false Table-prefixed value to used in the ORDER clause. False otherwise. since: 4.0.0 |
parse_order( $order ) X-Ref |
Parse an 'order' query variable and cast it to ASC or DESC as necessary. param: string $order The 'order' query variable. return: string The sanitized 'order' query variable. since: 4.0.0 |
set_404() X-Ref |
Sets the 404 property and saves whether query is feed. since: 2.0.0 |
get( $query_var, $default_value = '' ) X-Ref |
Retrieves the value of a query variable. param: string $query_var Query variable key. param: mixed $default_value Optional. Value to return if the query variable is not set. Default empty string. return: mixed Contents of the query variable. since: 1.5.0 since: 3.9.0 The `$default_value` argument was introduced. |
set( $query_var, $value ) X-Ref |
Sets the value of a query variable. param: string $query_var Query variable key. param: mixed $value Query variable value. since: 1.5.0 |
get_posts() X-Ref |
Retrieves an array of posts based on query variables. There are a few filters and actions that can be used to modify the post database query. return: WP_Post[]|int[] Array of post objects or post IDs. since: 1.5.0 |
set_found_posts( $q, $limits ) X-Ref |
Set up the amount of found posts and the number of pages (if limit clause was used) for the current query. param: array $q Query variables. param: string $limits LIMIT clauses of the query. since: 3.5.0 |
next_post() X-Ref |
Set up the next post and iterate current post index. return: WP_Post Next post. since: 1.5.0 |
the_post() X-Ref |
Sets up the current post. Retrieves the next post, sets up the post, sets the 'in the loop' property to true. since: 1.5.0 |
have_posts() X-Ref |
Determines whether there are more posts available in the loop. Calls the {@see 'loop_end'} action when the loop is complete. return: bool True if posts are available, false if end of the loop. since: 1.5.0 |
rewind_posts() X-Ref |
Rewind the posts and reset post index. since: 1.5.0 |
next_comment() X-Ref |
Iterate current comment index and return WP_Comment object. return: WP_Comment Comment object. since: 2.2.0 |
the_comment() X-Ref |
Sets up the current comment. since: 2.2.0 |
have_comments() X-Ref |
Whether there are more comments available. Automatically rewinds comments when finished. return: bool True if comments are available, false if no more comments. since: 2.2.0 |
rewind_comments() X-Ref |
Rewind the comments, resets the comment index and comment to first. since: 2.2.0 |
query( $query ) X-Ref |
Sets up the WordPress query by parsing query string. param: string|array $query URL query string or array of query arguments. return: WP_Post[]|int[] Array of post objects or post IDs. since: 1.5.0 |
get_queried_object() X-Ref |
Retrieves the currently queried object. If queried object is not set, then the queried object will be set from the category, tag, taxonomy, posts page, single post, page, or author query variable. After it is set up, it will be returned. return: WP_Term|WP_Post_Type|WP_Post|WP_User|null The queried object. since: 1.5.0 |
get_queried_object_id() X-Ref |
Retrieves the ID of the currently queried object. return: int since: 1.5.0 |
__construct( $query = '' ) X-Ref |
Constructor. Sets up the WordPress query, if parameter is not empty. param: string|array $query URL query string or array of vars. since: 1.5.0 |
__get( $name ) X-Ref |
Make private properties readable for backward compatibility. param: string $name Property to get. return: mixed Property. since: 4.0.0 |
__isset( $name ) X-Ref |
Make private properties checkable for backward compatibility. param: string $name Property to check if set. return: bool Whether the property is set. since: 4.0.0 |
__call( $name, $arguments ) X-Ref |
Make private/protected methods readable for backward compatibility. param: string $name Method to call. param: array $arguments Arguments to pass when calling. return: mixed|false Return value of the callback, false otherwise. since: 4.0.0 |
is_archive() X-Ref |
Is the query for an existing archive page? Archive pages include category, tag, author, date, custom post type, and custom taxonomy based archives. return: bool Whether the query is for an existing archive page. since: 3.1.0 |
is_post_type_archive( $post_types = '' ) X-Ref |
Is the query for an existing post type archive page? param: string|string[] $post_types Optional. Post type or array of posts types return: bool Whether the query is for an existing post type archive page. since: 3.1.0 |
is_attachment( $attachment = '' ) X-Ref |
Is the query for an existing attachment page? param: int|string|int[]|string[] $attachment Optional. Attachment ID, title, slug, or array of such return: bool Whether the query is for an existing attachment page. since: 3.1.0 |
is_author( $author = '' ) X-Ref |
Is the query for an existing author archive page? If the $author parameter is specified, this function will additionally check if the query is for one of the authors specified. param: int|string|int[]|string[] $author Optional. User ID, nickname, nicename, or array of such return: bool Whether the query is for an existing author archive page. since: 3.1.0 |
is_category( $category = '' ) X-Ref |
Is the query for an existing category archive page? If the $category parameter is specified, this function will additionally check if the query is for one of the categories specified. param: int|string|int[]|string[] $category Optional. Category ID, name, slug, or array of such return: bool Whether the query is for an existing category archive page. since: 3.1.0 |
is_tag( $tag = '' ) X-Ref |
Is the query for an existing tag archive page? If the $tag parameter is specified, this function will additionally check if the query is for one of the tags specified. param: int|string|int[]|string[] $tag Optional. Tag ID, name, slug, or array of such return: bool Whether the query is for an existing tag archive page. since: 3.1.0 |
is_tax( $taxonomy = '', $term = '' ) X-Ref |
Is the query for an existing custom taxonomy archive page? If the $taxonomy parameter is specified, this function will additionally check if the query is for that specific $taxonomy. If the $term parameter is specified in addition to the $taxonomy parameter, this function will additionally check if the query is for one of the terms specified. param: string|string[] $taxonomy Optional. Taxonomy slug or slugs to check against. param: int|string|int[]|string[] $term Optional. Term ID, name, slug, or array of such return: bool Whether the query is for an existing custom taxonomy archive page. since: 3.1.0 |
is_comments_popup() X-Ref |
Whether the current URL is within the comments popup window. return: false Always returns false. since: 3.1.0 |
is_date() X-Ref |
Is the query for an existing date archive? return: bool Whether the query is for an existing date archive. since: 3.1.0 |
is_day() X-Ref |
Is the query for an existing day archive? return: bool Whether the query is for an existing day archive. since: 3.1.0 |
is_feed( $feeds = '' ) X-Ref |
Is the query for a feed? param: string|string[] $feeds Optional. Feed type or array of feed types return: bool Whether the query is for a feed. since: 3.1.0 |
is_comment_feed() X-Ref |
Is the query for a comments feed? return: bool Whether the query is for a comments feed. since: 3.1.0 |
is_front_page() X-Ref |
Is the query for the front page of the site? This is for what is displayed at your site's main URL. Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_on_front'. If you set a static page for the front page of your site, this function will return true when viewing that page. Otherwise the same as @see WP_Query::is_home() return: bool Whether the query is for the front page of the site. since: 3.1.0 |
is_home() X-Ref |
Is the query for the blog homepage? This is the page which shows the time based blog content of your site. Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'. If you set a static page for the front page of your site, this function will return true only on the page you set as the "Posts page". return: bool Whether the query is for the blog homepage. since: 3.1.0 |
is_privacy_policy() X-Ref |
Is the query for the Privacy Policy page? This is the page which shows the Privacy Policy content of your site. Depends on the site's "Change your Privacy Policy page" Privacy Settings 'wp_page_for_privacy_policy'. This function will return true only on the page you set as the "Privacy Policy page". return: bool Whether the query is for the Privacy Policy page. since: 5.2.0 |
is_month() X-Ref |
Is the query for an existing month archive? return: bool Whether the query is for an existing month archive. since: 3.1.0 |
is_page( $page = '' ) X-Ref |
Is the query for an existing single page? If the $page parameter is specified, this function will additionally check if the query is for one of the pages specified. param: int|string|int[]|string[] $page Optional. Page ID, title, slug, path, or array of such return: bool Whether the query is for an existing single page. since: 3.1.0 |
is_paged() X-Ref |
Is the query for a paged result and not for the first page? return: bool Whether the query is for a paged result. since: 3.1.0 |
is_preview() X-Ref |
Is the query for a post or page preview? return: bool Whether the query is for a post or page preview. since: 3.1.0 |
is_robots() X-Ref |
Is the query for the robots.txt file? return: bool Whether the query is for the robots.txt file. since: 3.1.0 |
is_favicon() X-Ref |
Is the query for the favicon.ico file? return: bool Whether the query is for the favicon.ico file. since: 5.4.0 |
is_search() X-Ref |
Is the query for a search? return: bool Whether the query is for a search. since: 3.1.0 |
is_single( $post = '' ) X-Ref |
Is the query for an existing single post? Works for any post type excluding pages. If the $post parameter is specified, this function will additionally check if the query is for one of the Posts specified. param: int|string|int[]|string[] $post Optional. Post ID, title, slug, path, or array of such return: bool Whether the query is for an existing single post. since: 3.1.0 |
is_singular( $post_types = '' ) X-Ref |
Is the query for an existing single post of any post type (post, attachment, page, custom post types)? If the $post_types parameter is specified, this function will additionally check if the query is for one of the Posts Types specified. param: string|string[] $post_types Optional. Post type or array of post types return: bool Whether the query is for an existing single post since: 3.1.0 |
is_time() X-Ref |
Is the query for a specific time? return: bool Whether the query is for a specific time. since: 3.1.0 |
is_trackback() X-Ref |
Is the query for a trackback endpoint call? return: bool Whether the query is for a trackback endpoint call. since: 3.1.0 |
is_year() X-Ref |
Is the query for an existing year archive? return: bool Whether the query is for an existing year archive. since: 3.1.0 |
is_404() X-Ref |
Is the query a 404 (returns no results)? return: bool Whether the query is a 404 error. since: 3.1.0 |
is_embed() X-Ref |
Is the query for an embedded post? return: bool Whether the query is for an embedded post. since: 4.4.0 |
is_main_query() X-Ref |
Is the query the main query? return: bool Whether the query is the main query. since: 3.3.0 |
setup_postdata( $post ) X-Ref |
Set up global post data. param: WP_Post|object|int $post WP_Post instance or Post ID/object. return: true True when finished. since: 4.1.0 since: 4.4.0 Added the ability to pass a post ID to `$post`. |
generate_postdata( $post ) X-Ref |
Generate post data. param: WP_Post|object|int $post WP_Post instance or Post ID/object. return: array|false Elements of post or false on failure. since: 5.2.0 |
reset_postdata() X-Ref |
After looping through a nested query, this function restores the $post global to the current post in this query. since: 3.7.0 |
lazyload_term_meta( $check, $term_id ) X-Ref |
Lazyload term meta for posts in the loop. param: mixed $check param: int $term_id return: mixed since: 4.4.0 |
lazyload_comment_meta( $check, $comment_id ) X-Ref |
Lazyload comment meta for comments in the loop. param: mixed $check param: int $comment_id return: mixed since: 4.4.0 |
Generated: Fri Oct 4 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |