WordPress at a glance

Queries (рубрика)

get_page_by_title()

Retrieve any type of post (page, post, custom type) by given title.

get_post()

Gets the data of the current or specified post. You need to specify post ID, or the function will return the current post. Returns a WP_Post object.

get_posts()

Retrieve list of latest posts or posts matching criteria.

have_posts()

Checks if the current WP query has results for output, i.e. if there are posts available for output on the current page. Conditional tag.

in_the_loop()

Whether the caller is in the Loop.

is_404()

Is the query a 404 (returns no results)?

is_archive()

Conditional tag. Return true when any of the archive pages are shown (Year, Category, Author, Post Type archive...).

is_attachment()

Is the query for an existing attachment page?

is_author()

Is the query for an existing author archive page?

is_category()

Conditional tag. Checks whether the category page is displayed or not.

is_date()

Is the query for an existing date archive?

is_day()

Is the query for an existing day archive?

is_feed()

Is the query for a feed?

is_front_page()

Checks whether the main (home) page of the site is displayed. Conditional tag.

is_home()

The conditional tag that checks if the page with the last posts is displayed, usually it is the main page of the site or the blog homepage.

is_main_query()

Is the query the main query?

is_month()

Is the query for an existing month archive?

is_new_day()

Whether the publish date of the current post in the loop is different from the publish date of the previous post in the loop.

is_page()

Checks whether a "static page" is displaying. You can specify an ID, name, or page title to check a specific page. Conditional tag.

is_paged()

Checks whether the pagination page is displayed (page type /page/2, /page/3). Conditional tag.

is_preview()

Is the query for a post or page preview?

is_search()

Works when the search results page is displayed. Conditional tag.

is_single()

Checks whether the post page of any post type except attachment and page is displayed. Conditional tag.

is_singular()

Checks whether the post page is viewed (post, page, attachment, any post type). Conditional Tag.

is_tag()

Is the query for an existing tag archive page?

is_tax()

Works on the custom taxonomy archive page. Conditional tag.

is_time()

Is the query for a specific time?

is_year()

Is the query for an existing year archive?

query_posts()

Sets up The Loop with query parameters.

rewind_posts()

Rewind the loop posts.

setup_postdata()

Set up the global post data. Useful for easy usage of Template Tags related to the design of the post: the_title(), the_permalink(), etc.

the_post()

Iterate the post index in the loop. Gets the next post, overrides the global variable $post, and sets in the loop property to true.

wp_count_posts()

Gets the number of posts of any post type and any status (publish, draft).

wp_get_recent_posts()

Retrieve the last posts of the website, including drafts, scheduled, and posts on moderation. Gets the last 10 posts only.

wp_reset_postdata()

Restores the global $post variable to the correct state: current post in the main query.

wp_reset_query()

Invalidates (destroys) the data of the last query created for use in an arbitrary WordPress Loop and restores the default loop data.