WP Query post by year in accordion
问题 I'm trying to get the testimonials (custom post type) in following order. I can easily retrieve posts using WP_Query class but struggling to create an accordion as shown in the screenshot above. 回答1: Try using a custom select query and looping through each post with a post_type of testimonial. Then loop through result and set WP_Query() class date_query param to an array of the years obtained by the custom select query result. global $wpdb; $posts = $wpdb->posts; //Get all unique years as