• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Show Posts Between Specific Date Period

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.

Register for full access

Date Parameters

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’.

Usage

There’s several ways to displays the posts within this date period.

  1. 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.
  2. For Genesis users, you can use the args in this code to create your own custom_genesis_loop.
  3. 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' ); ?>

Related Posts

  • Genesis Yearly Template To List All Posts For Each Month In a Responsive Grid
  • Genesis Template To Display Posts by Year
  • Widgets Which Display Automatically For Each Day Of The Week

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags