[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> query.php (summary)

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: 1163 lines (33 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 46 functions

  get_query_var()
  get_queried_object()
  get_queried_object_id()
  set_query_var()
  query_posts()
  wp_reset_query()
  wp_reset_postdata()
  is_archive()
  is_post_type_archive()
  is_attachment()
  is_author()
  is_category()
  is_tag()
  is_tax()
  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_search()
  is_single()
  is_singular()
  is_time()
  is_trackback()
  is_year()
  is_404()
  is_embed()
  is_main_query()
  have_posts()
  in_the_loop()
  rewind_posts()
  the_post()
  have_comments()
  the_comment()
  wp_old_slug_redirect()
  _find_post_by_old_slug()
  _find_post_by_old_date()
  setup_postdata()
  generate_postdata()

Functions
Functions that are not part of a class:

get_query_var( $var, $default = '' )   X-Ref
Retrieve variable in the WP_Query class.

since: 1.5.0
since: 3.9.0 The `$default` argument was introduced.
param: string $var       The variable key to retrieve.
param: mixed  $default   Optional. Value to return if the query variable is not set. Default empty.
return: mixed Contents of the query variable.

get_queried_object()   X-Ref
Retrieve the currently-queried object.

Wrapper for WP_Query::get_queried_object().

since: 3.1.0
return: object Queried object.

get_queried_object_id()   X-Ref
Retrieve ID of the current queried object.

Wrapper for WP_Query::get_queried_object_id().

since: 3.1.0
return: int ID of the queried object.

set_query_var( $var, $value )   X-Ref
Set query variable.

since: 2.2.0
param: string $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.

since: 1.5.0
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.

since: 2.3.0

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.

since: 3.0.0

is_archive()   X-Ref
Determines whether the query is for an existing archive page.

Month, Year, Category, Author, Post Type 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.

since: 1.5.0
return: bool

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.

since: 3.1.0
param: string|array $post_types Optional. Post type or array of posts types to check against.
return: bool

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.

since: 2.0.0
param: int|string|array|object $attachment Attachment ID, title, slug, or array of such.
return: bool

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.

since: 1.5.0
param: mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
return: bool

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.

since: 1.5.0
param: mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
return: bool

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.

since: 2.3.0
param: mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs.
return: bool

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.

since: 2.5.0
param: string|array     $taxonomy Optional. Taxonomy slug or slugs.
param: int|string|array $term     Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
return: bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives).

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.

since: 1.5.0
return: bool

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.

since: 1.5.0
return: bool

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.

since: 1.5.0
param: string|array $feeds Optional feed types to check.
return: bool

is_comment_feed()   X-Ref
Is the query for a comments feed?

since: 3.0.0
return: bool

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.

since: 2.5.0
return: bool True, if front of 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.

since: 1.5.0
return: bool True if blog view homepage, otherwise false.

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.

since: 5.2.0
return: bool

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.

since: 1.5.0
return: bool

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.

since: 1.5.0
param: int|string|array $page Optional. Page ID, title, slug, or array of such. Default empty.
return: bool Whether the query is for an existing single page.

is_paged()   X-Ref
Determines whether the query is for paged results 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.

since: 1.5.0
return: bool

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.

since: 2.0.0
return: bool

is_robots()   X-Ref
Is the query for the robots file?

since: 2.1.0
return: bool

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.

since: 1.5.0
return: bool

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.

since: 1.5.0
param: int|string|array $post Optional. Post ID, title, slug, or array of such. Default empty.
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.

since: 1.5.0
param: string|array $post_types Optional. Post type or array of post types. Default empty.
return: bool Whether the query is for an existing single post of any of the given post types.

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.

since: 1.5.0
return: bool

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.

since: 1.5.0
return: bool

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.

since: 1.5.0
return: bool

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.

since: 1.5.0
return: bool

is_embed()   X-Ref
Is the query for an embedded post?

since: 4.4.0
return: bool Whether we're in an embedded post or not.

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.

since: 3.3.0
return: bool

have_posts()   X-Ref
Whether current WordPress query has results to loop over.

since: 1.5.0
return: bool

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.

since: 2.0.0
return: bool True if caller is within loop, false if loop hasn't started or ended.

rewind_posts()   X-Ref
Rewind the loop posts.

since: 1.5.0

the_post()   X-Ref
Iterate the post index in the loop.

since: 1.5.0

have_comments()   X-Ref
Whether there are comments to loop over.

since: 2.2.0
return: bool

the_comment()   X-Ref
Iterate comment index in the comment loop.

since: 2.2.0
return: object

wp_old_slug_redirect()   X-Ref
Redirect old slugs to the correct permalink.

Attempts to find the current slug from the past slugs.

since: 2.1.0

_find_post_by_old_slug( $post_type )   X-Ref
Find the post ID for redirecting an old slug.

since: 4.9.3
param: string $post_type The current post type based on the query vars.
return: int $id The Post ID.

_find_post_by_old_date( $post_type )   X-Ref
Find the post ID for redirecting an old date.

since: 4.9.3
param: string $post_type The current post type based on the query vars.
return: int $id The Post ID.

setup_postdata( $post )   X-Ref
Set up global post data.

since: 1.5.0
since: 4.4.0 Added the ability to pass a post ID to `$post`.
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.

since: 5.2.0
param: WP_Post|object|int $post WP_Post instance or Post ID/object.
return: array|bool Elements of post, or false on failure.



Generated: Mon Dec 9 01:00:03 2019 Cross-referenced by PHPXref 0.7.1