To solve this problem, we’ll create a custom Gutenberg block in WordPress that lists terms from a selected taxonomy, displaying only posts with future event dates. We’ll use ACF for custom fields, specifically for selecting the post type and taxonomy, as well as storing event start dates. The solution involves querying posts with WP_Query and filtering them based on the event dates.

Step-by-Step Guide

  1. Create the Custom Block: Register a custom Gutenberg block that will handle displaying the list of terms and their posts.
  2. Fetch ACF Fields:Retrieve the selected post type and taxonomy using ACF. Default to `post` and `category` if these fields are empty.
  3. Fetch and Filter Terms: Fetch terms from the selected taxonomy and check if each term has posts with future event dates or no date set.
  4. Filter Posts Based on Event Date: For each term, query the posts and filter out those with past event dates. Only include posts with future dates or no date set.
  5. Display the Terms and Posts: Output the terms with their descriptions and the list of filtered posts. Ensure the event start date is formatted and displayed after the post title.

Below is a code example that demonstrates this approach: