[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
WordPress Query API The query API attempts to get which part of WordPress the user is on. It also provides functionality for getting URL query information.
File Size: | 1257 lines (37 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
get_query_var( $query_var, $default_value = '' ) X-Ref |
Retrieves the value of a query variable in the WP_Query class. param: string $query_var The variable key to retrieve. param: mixed $default_value Optional. Value to return if the query variable is not set. return: mixed Contents of the query variable. |
get_queried_object() X-Ref |
Retrieves the currently queried object. Wrapper for WP_Query::get_queried_object(). return: WP_Term|WP_Post_Type|WP_Post|WP_User|null The queried object. |
get_queried_object_id() X-Ref |
Retrieves the ID of the currently queried object. Wrapper for WP_Query::get_queried_object_id(). return: int ID of the queried object. |
set_query_var( $query_var, $value ) X-Ref |
Sets the value of a query variable in the WP_Query class. param: string $query_var Query variable key. param: mixed $value Query variable value. |
query_posts( $query ) X-Ref |
Sets up The Loop with query parameters. Note: This function will completely override the main query and isn't intended for use by plugins or themes. Its overly-simplistic approach to modifying the main query can be problematic and should be avoided wherever possible. In most cases, there are better, more performant options for modifying the main query such as via the {@see 'pre_get_posts'} action within WP_Query. This must not be used within the WordPress Loop. param: array|string $query Array or string of WP_Query arguments. return: WP_Post[]|int[] Array of post objects or post IDs. |
wp_reset_query() X-Ref |
Destroys the previous query and sets up a new query. This should be used after query_posts() and before another query_posts(). This will remove obscure bugs that occur when the previous WP_Query object is not destroyed properly before another is set up. |
wp_reset_postdata() X-Ref |
After looping through a separate query, this function restores the $post global to the current post in the main query. |
is_archive() X-Ref |
Determines whether the query is for an existing archive page. Archive pages include category, tag, author, date, custom post type, and custom taxonomy based archives. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for an existing archive page. |
is_post_type_archive( $post_types = '' ) X-Ref |
Determines whether the query is for an existing post type archive page. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. 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. |
is_attachment( $attachment = '' ) X-Ref |
Determines whether the query is for an existing attachment page. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. 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. |
is_author( $author = '' ) X-Ref |
Determines whether the query is 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. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. 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. |
is_category( $category = '' ) X-Ref |
Determines whether the query is 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. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. 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. |
is_tag( $tag = '' ) X-Ref |
Determines whether the query is 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. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. 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. |
is_tax( $taxonomy = '', $term = '' ) X-Ref |
Determines whether the query is 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. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. 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. |
is_date() X-Ref |
Determines whether the query is for an existing date archive. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for an existing date archive. |
is_day() X-Ref |
Determines whether the query is for an existing day archive. A conditional check to test whether the page is a date-based archive page displaying posts for the current day. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for an existing day archive. |
is_feed( $feeds = '' ) X-Ref |
Determines whether the query is for a feed. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. param: string|string[] $feeds Optional. Feed type or array of feed types return: bool Whether the query is for a feed. |
is_comment_feed() X-Ref |
Is the query for a comments feed? return: bool Whether the query is for a comments feed. |
is_front_page() X-Ref |
Determines whether the query is 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 is_home()}. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for the front page of the site. |
is_home() X-Ref |
Determines whether the query is for the blog homepage. The blog homepage is the page that shows the time-based blog content of the site. is_home() is dependent on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'. If a static page is set for the front page of the site, this function will return true only on the page you set as the "Posts page". For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for the blog homepage. |
is_privacy_policy() X-Ref |
Determines whether the query is for the Privacy Policy page. The Privacy Policy page is the page that shows the Privacy Policy content of the site. is_privacy_policy() is dependent 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". For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for the Privacy Policy page. |
is_month() X-Ref |
Determines whether the query is for an existing month archive. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for an existing month archive. |
is_page( $page = '' ) X-Ref |
Determines whether the query is 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. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. param: int|string|int[]|string[] $page Optional. Page ID, title, slug, or array of such return: bool Whether the query is for an existing single page. |
is_paged() X-Ref |
Determines whether the query is for a paged result and not for the first page. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for a paged result. |
is_preview() X-Ref |
Determines whether the query is for a post or page preview. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for a post or page preview. |
is_robots() X-Ref |
Is the query for the robots.txt file? return: bool Whether the query is for the robots.txt file. |
is_favicon() X-Ref |
Is the query for the favicon.ico file? return: bool Whether the query is for the favicon.ico file. |
is_search() X-Ref |
Determines whether the query is for a search. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for a search. |
is_single( $post = '' ) X-Ref |
Determines whether the query is for an existing single post. Works for any post type, except attachments and pages If the $post parameter is specified, this function will additionally check if the query is for one of the Posts specified. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. param: int|string|int[]|string[] $post Optional. Post ID, title, slug, or array of such return: bool Whether the query is for an existing single post. |
is_singular( $post_types = '' ) X-Ref |
Determines whether the query is 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. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. param: string|string[] $post_types Optional. Post type or array of post types return: bool Whether the query is for an existing single post |
is_time() X-Ref |
Determines whether the query is for a specific time. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for a specific time. |
is_trackback() X-Ref |
Determines whether the query is for a trackback endpoint call. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for a trackback endpoint call. |
is_year() X-Ref |
Determines whether the query is for an existing year archive. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is for an existing year archive. |
is_404() X-Ref |
Determines whether the query has resulted in a 404 (returns no results). For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is a 404 error. |
is_embed() X-Ref |
Is the query for an embedded post? return: bool Whether the query is for an embedded post. |
is_main_query() X-Ref |
Determines whether the query is the main query. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool Whether the query is the main query. |
have_posts() X-Ref |
Determines whether current WordPress query has posts to loop over. return: bool True if posts are available, false if end of the loop. |
in_the_loop() X-Ref |
Determines whether the caller is in the Loop. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool True if caller is within loop, false if loop hasn't started or ended. |
rewind_posts() X-Ref |
Rewind the loop posts. |
the_post() X-Ref |
Iterate the post index in the loop. |
have_comments() X-Ref |
Determines whether current WordPress query has comments to loop over. return: bool True if comments are available, false if no more comments. |
the_comment() X-Ref |
Iterate comment index in the comment loop. |
wp_old_slug_redirect() X-Ref |
Redirect old slugs to the correct permalink. Attempts to find the current slug from the past slugs. |
_find_post_by_old_slug( $post_type ) X-Ref |
Find the post ID for redirecting an old slug. param: string $post_type The current post type based on the query vars. return: int The Post ID. |
_find_post_by_old_date( $post_type ) X-Ref |
Find the post ID for redirecting an old date. param: string $post_type The current post type based on the query vars. return: int The Post ID. |
setup_postdata( $post ) X-Ref |
Set up global post data. param: WP_Post|object|int $post WP_Post instance or Post ID/object. return: bool True when finished. |
generate_postdata( $post ) X-Ref |
Generates 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. |
Generated : Tue Dec 24 08:20:01 2024 | Cross-referenced by PHPXref |