Mastering WP_Query: An Introduction
read more
Categories

Mastering WP_Query: An Introduction


By default, WordPress will run a query on each page that your site displays, the nature of which will be determined by the type of page being viewed. So if a static page is being viewed, WordPress runs a query to display the page with the relevant ID, while if an archive page is being viewed, the query will retrieve all posts in that archive.

But sometimes you want to do things a bit differently. Either in your page’s main content or elsewhere on the page (such as in the sidebar or footer), you might want to display some specific content which isn’t output by the standard query.

The great news is that WordPress makes that possible with the WP_Query class.