Query refers to the database query that WordPress uses in the Loop to find the list of posts that are to be displayed on the screen. By default, the WordPress query searches for posts that belong to the currently-requested page. No matter it is a single post, single static page, category archive, date archive, search results, feed, or the main list of blog posts; the query is limited to a certain maximum number of posts, and the posts are retrieved in reverse-date order. A plugin may use a custom query to override this behavior.
Here are some examples:
- Display posts in a different order, such as alphabetically for a “glossary” category.
- Override the default number of posts to be displayed on the page; for example, the glossary plugin may want to have a higher post limit when displaying the glossary category.
- Exclude certain posts from certain pages; for instance, posts from the glossary category might be excluded from the home page and archive pages, and appear only on their own category page.
- Expand the default WordPress keyword search to search in other fields, such as the city, state, and country fields of a geographical tagging plugin.
- Allow custom URLs such as example.com/blog?geostate=oregon or example.com/blog/geostate/oregon to refer to the archive of posts tagged with the state of Oregon.