Filter Custom Post Types By Date Range (Two Custom Date Fields)
I have created a custom post type called ‘books’. Currently trying to use two custom fields that are both dates called:
offer_start_date and offer_end_date
They display perfectly on the admin panel using Admin Columns. However there was a need to filter the data, so I purchased a license for Pro.
Having implemented this, it doesn’t actually filter the dates in the way I thought it would.
Can you explain to me how I can get it so that when I click on “Filter”:
1. offer_start_date … instead of being compared to it’s exact value and only bring back everything with that exact start date, can you tell me how to make it it will bring back everything with that start date and after that start date?
2. offer_end_date … pretty much the same, but can you tell me how to bring back everything that’s ends on that date, or before it.
Obviously, these two filter queries need to work together, thus giving me “Books” that have a offer_start_date and offer_end_date within the two specified dates in the filter
I have had a look through the forum here and can’t find anything relate to this, or even doing this manually for a custom post type, but from that logic I feel it should be easy enough, that is however if my logic is sound, which it may not be.
- The topic ‘Filter Custom Post Types By Date Range (Two Custom Date Fields)’ is closed to new replies.