12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Mar 11, 2020

CPT entries grouped by a custom taxonomy and filtered by a Date Field

Sridhar Katakam

In the WPDevDesign Facebook group, a user asked:

In this members-only tutorial, we shall

  • loop through all the terms of a book_category taxonomy
  • construct a meta query array wherein a date_live date field added using ACF is checked for its value between the first and last days of the current month
  • for each taxonomy term create a WP_Query object having all the entries of the book post type that belong to that term AND meeting the above meta query requirement i.e., the month of date-type custom field's value matching the current month.
  • output the taxonomy term headings and book titles in the loop

to have entries of a CPT grouped by a taxonomy where the date-type custom field's value falls in the current month.

Here's the Code

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.