One of the most powerful aspects of the WordPress API is WP_Query
as it allows us to retrieve a wide variety of content through a relatively simple interface.
That is, it allows us to retrieve complicated datasets ranging from custom post types, post status, date ranges, taxonomies, meta data, categories, and so on all with a relatively standard set of PHP constructs (mainly arrays) and with a really solid reference in the associated Codex article.
One of the nicest things about WP_Query
, especially since WordPress 3.7, are the advanced date query parameters that we can use in order to retrieve information from a specific date range without having to do a lot of complicated date math (which, of course, is every programmer’s favorite aspect of development).
If you learn how to use that particular aspect of WP_Query and you’re familiar with PHP’s strtotime function, then you can retrieve posts from a range of dates easily.
Continue reading