A list of all WordPress query types

Last Updated on: 21st February 2023, 11:05 pm

Lately I have been playing around with pre_get_posts much and wanted to know all kinds of query types one can use to form a conditional statement. I did not find a good list, so I created my own.

Here are the WordPress query types that I found exist, along with their corresponding is_ functions:

  1. is_404() – Returns true if the current page is a 404 error page.
  2. is_admin() – Returns true if the current page is an admin page.
  3. is_archive() – Returns true if the current page is an archive page.
  4. is_attachment() – Returns true if the current page is an attachment page.
  5. is_author() – Returns true if the current page is an author archive page.
  6. is_category() – Returns true if the current page is a category archive page.
  7. is_comments_popup() – Returns true if the current page is a comments popup window.
  8. is_date() – Returns true if the current page is a date archive page.
  9. is_day() – Returns true if the current page is a day archive page.
  10. is_feed() – Returns true if the current page is a feed page.
  11. is_front_page() – Returns true if the current page is the front page.
  12. is_home() – Returns true if the current page is the home page.
  13. is_month() – Returns true if the current page is a month archive page.
  14. is_page() – Returns true if the current page is a page.
  15. is_paged() – Returns true if the current page is paginated (returns only true starting on the 2nd page onwards, not the first).
  16. is_preview() – Returns true if the current page is a preview page.
  17. is_search() – Returns true if the current page is a search results page.
  18. is_single() – Returns true if the current page is a single post page.
  19. is_singular() – Returns true if the current page is a singular page (page, post, or attachment).
  20. is_tag() – Returns true if the current page is a tag archive page.
  21. is_tax() – Returns true if the current page is a taxonomy archive page.
  22. is_time() – Returns true if the current page is a time archive page.
  23. is_trackback() – Returns true if the current page is a trackback page.
  24. is_year() – Returns true if the current page is a year archive page.

These functions can be used in conjunction with conditional statements to customize the output of your WordPress site based on the current query. For example:

if ( is_home() ) {
// Display something on the home page
}
elseif ( is_single() ) {
// Display something on a single post page
} else {
// Display something else on all other pages
}

Note that not all query types will apply to every page of your WordPress site, depending on your site’s content and organization.

Leave a Reply

Your email address will not be published. Required fields are marked *

Con Schneider