Since version 3.7 of WordPress was released, you can create a new WP_Query and use the date_query parameter to display posts within a certain date range.
after – Date to retrieve posts after. Accepts array of ‘year’, ‘month’, ‘day’ values.
before – Date to retrieve posts before. Accepts array of ‘year’, ‘month’, ‘day’ values.
year – 4 digit year (e.g. 2011).
month – Month number (from 1 to 12).
day – Day of the month (from 1 to 31).
inclusive – For after/before, whether exact value should be matched or not’.
There’s several ways to displays the posts within this date period.
- You can copy of the file from your parent theme and modify your loop in a child theme which is what you should do if using one of the default parent themes like Twenty Fourteen etc.
- For Genesis users, you can use the args in this code to create your own custom_genesis_loop.
- Or you could add this code to a new file and use get_template_part to display it in any template file or in a custom function with hook and conditional tag.
<?php get_template_part( 'specific_dates' ); ?>
Leave a Reply
You must be logged in to post a comment.