Class WP_Query

Description

The WordPress Query class.

Located in /ptests/samples/omitted/query.php (line 822)


	
			
Variable Summary
Method Summary
 WP_Query __construct ([string $query = ''])
 array fill_query_vars (array $array)
 mixed get (string $query_var)
 array &get_posts ()
 object get_queried_object ()
 bool have_comments ()
 bool have_posts ()
 void init ()
 bool is_404 ()
 bool is_archive ()
 bool is_attachment ()
 bool is_author ([mixed $author = ''])
 bool is_category ([mixed $category = ''])
 bool is_comment_feed ()
 bool is_date ()
 bool is_day ()
 bool is_feed ([string|array $feeds = ''])
 bool is_front_page ()
 bool is_home ()
 bool is_month ()
 bool is_page ([mixed $page = ''])
 bool is_paged ()
 bool is_post_type_archive ([mixed $post_types = ''])
 bool is_preview ()
 bool is_robots ()
 bool is_search ()
 bool is_single ([mixed $post = ''])
 bool is_singular ([mixed $post_types = ''])
 bool is_tag ([mixed $slug = ''])
 bool is_tax ([mixed $taxonomy = ''], [ $term = ''], mixed $term.)
 bool is_time ()
 bool is_trackback ()
 bool is_year ()
 object Comment next_comment ()
 object Next next_post ()
 void parse_query ([string|array $query = ''])
 void parse_tax_query ( &$q)
 array &query (string $query)
 void rewind_comments ()
 void rewind_posts ()
 void set (string $query_var, mixed $value)
 void set_404 ()
 void the_comment ()
 void the_post ()
Variables
int $comment (line 968)

Current comment ID.

  • since: 2.2.0
  • access: public
array $comments (line 941)

The list of comments for current post.

  • since: 2.2.0
  • access: public
int $comment_count = 0 (line 950)

The amount of comments for the posts.

  • since: 2.2.0
  • access: public
int $current_comment = -1 (line 959)

The index of the comment in the comment loop.

  • since: 2.2.0
  • access: public
int $current_post = -1 (line 914)

Index of the current item in the loop.

  • since: 1.5.0
  • access: public
int $found_posts = 0 (line 977)

Amount of posts if limit clause was not used.

  • since: 2.1.0
  • access: public
bool $in_the_loop = false (line 923)

Whether the loop has started and the caller is in the loop.

  • since: 2.0.0
  • access: public
bool $is_404 = false (line 1166)

Set if query couldn't found anything.

  • since: 1.5.0
  • access: public
bool $is_admin = false (line 1193)

Set if query is part of administration page.

  • since: 1.5.0
  • access: public
bool $is_archive = false (line 1031)

Set if query is an archive list.

  • since: 1.5.0
  • access: public
bool $is_attachment = false (line 1202)

Set if query is an attachment.

  • since: 2.0.0
  • access: public
bool $is_author = false (line 1085)

Set if query contains an author.

  • since: 1.5.0
  • access: public
bool $is_category = false (line 1094)

Set if query contains category.

  • since: 1.5.0
  • access: public
bool $is_comments_popup = false (line 1175)

Set if query is within comments popup window.

  • since: 1.5.0
  • access: public
bool $is_comment_feed = false (line 1139)

Set if query is comment feed display.

  • since: 2.2.0
  • access: public
bool $is_date = false (line 1040)

Set if query is part of a date.

  • since: 1.5.0
  • access: public
bool $is_day = false (line 1067)

Set if query contains a day.

  • since: 1.5.0
  • access: public
bool $is_feed = false (line 1130)

Set if query is feed display.

  • since: 1.5.0
  • access: public
bool $is_home = false (line 1157)

Set if query is blog homepage.

  • since: 1.5.0
  • access: public
bool $is_month = false (line 1058)

Set if query contains a month.

  • since: 1.5.0
  • access: public
bool $is_page = false (line 1022)

Set if query returns a page.

  • since: 1.5.0
  • access: public
bool $is_paged = false (line 1184)

Set if query is paged

  • since: 1.5.0
  • access: public
bool $is_posts_page = false (line 1231)

Set if query contains posts.

Basically, the homepage if the option isn't set for the static homepage.

  • since: 2.1.0
  • access: public
bool $is_post_type_archive = false (line 1240)

Set if query is for a post type archive.

  • since: 3.1.0
  • access: public
bool $is_preview = false (line 1013)

Set if query is preview of blog.

  • since: 2.0.0
  • access: public
bool $is_robots = false (line 1220)

Set if query is for robots.

  • since: 2.1.0
  • access: public
bool $is_search = false (line 1121)

Set if query was part of a search result.

  • since: 1.5.0
  • access: public
bool $is_single = false (line 1004)

Set if query is single post.

  • since: 1.5.0
  • access: public
bool $is_singular = false (line 1211)

Set if is single, is a page, or is an attachment.

  • since: 2.1.0
  • access: public
bool $is_tag = false (line 1103)

Set if query contains tag.

  • since: 2.3.0
  • access: public
bool $is_tax = false (line 1112)

Set if query contains taxonomy.

  • since: 2.5.0
  • access: public
bool $is_time = false (line 1076)

Set if query contains time.

  • since: 1.5.0
  • access: public
bool $is_trackback = false (line 1148)

Set if query is trackback.

  • since: 1.5.0
  • access: public
bool $is_year = false (line 1049)

Set if query contains a year.

  • since: 1.5.0
  • access: public
int $max_num_comment_pages = 0 (line 995)

The amount of comment pages.

  • since: 2.7.0
  • access: public
int $max_num_pages = 0 (line 986)

The amount of pages.

  • since: 2.1.0
  • access: public
object WP_Meta_Query $meta_query = false (line 858)

Metadata query container

  • since: 3.2.0
  • access: public
object $post (line 932)

The current post ID.

array $posts (line 896)

List of posts.

  • since: 1.5.0
  • access: public
int $post_count = 0 (line 905)

The amount of posts for the current query.

  • since: 1.5.0
  • access: public
object|array $queried_object (line 869)

Holds the data for a single object that is queried.

Holds the contents of a post, page, category, attachment.

  • since: 1.5.0
  • access: public
int $queried_object_id (line 878)

The ID of the queried object.

  • since: 1.5.0
  • access: public
array $query (line 831)

Query vars set by the user

  • since: 1.5.0
  • access: public
array $query_vars = array() (line 840)

Query vars, after parsing

  • since: 1.5.0
  • access: public
string $request (line 887)

Get post database query.

  • since: 2.0.1
  • access: public
object WP_Tax_Query $tax_query (line 849)

Taxonomy query, as passed to get_tax_sql()

  • since: 3.1.0
  • access: public
bool $thumbnails_cached = false (line 1267)

Set if post thumbnails are cached

  • since: 3.2.0
  • access: public
Methods
Constructor __construct (line 2989)

Constructor.

Sets up the WordPress query, if parameter is not empty.

  • since: 1.5.0
  • access: public
WP_Query __construct ([string $query = ''])
  • string $query: URL query string.
fill_query_vars (line 1354)

Fills in the query variables, which do not exist within the parameter.

  • return: Complete query variables with undefined ones filled in empty.
  • since: 2.1.0
  • access: public
array fill_query_vars (array $array)
  • array $array: Defined query variables.
get (line 1874)

Retrieve query variable.

  • since: 1.5.0
  • access: public
mixed get (string $query_var)
  • string $query_var: Query variable key.
get_posts (line 1906)

Retrieve the posts based on query variables.

There are a few filters and actions that can be used to modify the post database query.

  • return: List of posts.
  • since: 1.5.0
  • access: public
  • uses: do_action_ref_array() - Calls 'pre_get_posts' hook before retrieving posts.
array &get_posts ()
get_queried_object (line 2919)

Retrieve 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.

  • since: 1.5.0
  • access: public
object get_queried_object ()
get_queried_object_id (line 2968)

Retrieve ID of the current queried object.

int get_queried_object_id ()
have_comments (line 2869)

Whether there are more comments available.

Automatically rewinds comments when finished.

  • return: True, if more comments. False, if no more posts.
  • since: 2.2.0
  • access: public
bool have_comments ()
have_posts (line 2800)

Whether there are more posts available in the loop.

Calls action 'loop_end', when the loop is complete.

  • return: True if posts are available, false if end of loop.
  • since: 1.5.0
  • access: public
  • uses: do_action_ref_array() - Calls 'loop_end' if loop is ended
bool have_posts ()
init (line 1313)

Initiates object properties and sets default values.

  • since: 1.5.0
  • access: public
void init ()
is_404 (line 3467)

Is the query a 404 (returns no results)?

  • since: 3.1.0
bool is_404 ()
is_archive (line 3004)

Is the query for an archive page?

Month, Year, Category, Author, Post Type archive...

  • since: 3.1.0
bool is_archive ()
is_attachment (line 3032)

Is the query for an attachment page?

  • since: 3.1.0
bool is_attachment ()
is_author (line 3047)

Is the query for an author archive page?

If the $author parameter is specified, this function will additionally check if the query is for one of the authors specified.

  • since: 3.1.0
bool is_author ([mixed $author = ''])
  • mixed $author: Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
is_category (line 3079)

Is the query for a category archive page?

If the $category parameter is specified, this function will additionally check if the query is for one of the categories specified.

  • since: 3.1.0
bool is_category ([mixed $category = ''])
  • mixed $category: Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
is_comments_popup (line 3174)

Whether the current URL is within the comments popup window.

  • since: 3.1.0
bool is_comments_popup ()
is_comment_feed (line 3225)

Is the query for a comments feed?

  • since: 3.1.0
bool is_comment_feed ()
is_date (line 3185)

Is the query for a date archive?

  • since: 3.1.0
bool is_date ()
is_day (line 3197)

Is the query for a day archive?

  • since: 3.1.0
bool is_day ()
is_feed (line 3209)

Is the query for a feed?

  • since: 3.1.0
bool is_feed ([string|array $feeds = ''])
  • string|array $feeds: Optional feed types to check.
is_front_page (line 3247)

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()

bool is_front_page ()
is_home (line 3273)

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".

bool is_home ()
is_month (line 3284)

Is the query for a month archive?

  • since: 3.1.0
bool is_month ()
is_page (line 3302)

Is the query for a single page?

If the $page parameter is specified, this function will additionally check if the query is for one of the pages specified.

bool is_page ([mixed $page = ''])
  • mixed $page: Page ID, title, slug, or array of such.
is_paged (line 3330)

Is the query for paged result and not for the first page?

  • since: 3.1.0
bool is_paged ()
is_post_type_archive (line 3016)

Is the query for a post type archive page?

  • since: 3.1.0
bool is_post_type_archive ([mixed $post_types = ''])
  • mixed $post_types: Optional. Post type or array of posts types to check against.
is_preview (line 3341)

Is the query for a post or page preview?

  • since: 3.1.0
bool is_preview ()
is_robots (line 3352)

Is the query for the robots file?

  • since: 3.1.0
bool is_robots ()
is_search (line 3363)

Is the query for a search?

  • since: 3.1.0
bool is_search ()
is_single (line 3383)

Is the query for a 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.

bool is_single ([mixed $post = ''])
  • mixed $post: Post ID, title, slug, or array of such.
is_singular (line 3418)

Is the query for a single post of any post type (post, attachment, page, ... )?

If the $post_types parameter is specified, this function will additionally check if the query is for one of the Posts Types specified.

bool is_singular ([mixed $post_types = ''])
  • mixed $post_types: Optional. Post Type or array of Post Types
is_tag (line 3111)

Is the query for a tag archive page?

If the $tag parameter is specified, this function will additionally check if the query is for one of the tags specified.

  • since: 3.1.0
bool is_tag ([mixed $slug = ''])
  • mixed $slug: Optional. Tag slug or array of slugs.
is_tax (line 3144)

Is the query for a 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.

  • since: 3.1.0
bool is_tax ([mixed $taxonomy = ''], [ $term = ''], mixed $term.)
  • mixed $taxonomy: Optional. Taxonomy slug or slugs.
  • mixed $term.: Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
  • $term
is_time (line 3434)

Is the query for a specific time?

  • since: 3.1.0
bool is_time ()
is_trackback (line 3445)

Is the query for a trackback endpoint call?

  • since: 3.1.0
bool is_trackback ()
is_year (line 3456)

Is the query for a specific year?

  • since: 3.1.0
bool is_year ()
next_comment (line 2834)

Iterate current comment index and return comment object.

  • return: object.
  • since: 2.2.0
  • access: public
object Comment next_comment ()
next_post (line 2759)

Set up the next post and iterate current post index.

  • return: post.
  • since: 1.5.0
  • access: public
object Next next_post ()
parse_query (line 1415)

Parse a query string and set query type booleans.

  • since: 1.5.0
  • access: public
void parse_query ([string|array $query = ''])
  • string|array $query: Optional query.
parse_query_vars (line 1341)

Reparse the query vars.

  • since: 1.5.0
  • access: public
void parse_query_vars ()
parse_tax_query (line 1674)
void parse_tax_query ( &$q)
  • &$q
query (line 2901)

Sets up the WordPress query by parsing query string.

  • return: List of posts.
  • since: 1.5.0
  • access: public
array &query (string $query)
  • string $query: URL query string.
rewind_comments (line 2885)

Rewind the comments, resets the comment index and comment to first.

  • since: 2.2.0
  • access: public
void rewind_comments ()
rewind_posts (line 2819)

Rewind the posts and reset post index.

  • since: 1.5.0
  • access: public
void rewind_posts ()
set (line 1890)

Set query variable.

  • since: 1.5.0
  • access: public
void set (string $query_var, mixed $value)
  • string $query_var: Query variable key.
  • mixed $value: Query variable value.
set_404 (line 1856)

Sets the 404 property and saves whether query is feed.

  • since: 2.0.0
  • access: public
void set_404 ()
the_comment (line 2849)

Sets up the current comment.

  • since: 2.2.0
  • access: public
  • uses: do_action() - Calls 'comment_loop_start' hook when first comment is processed.
void the_comment ()
the_post (line 2778)

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
  • access: public
  • uses: do_action_ref_array() - Calls 'loop_start' if loop has just started
  • uses: WP_Query::$post
void the_post ()

Documentation generated on Thu, 29 Sep 2011 01:44:46 +0530 by phpDocumentor 1.4.3