Query distinct years in a category
-
I’m building out a custom archive widget that displays a select dropdown of months for each year.
How can I extend this query to to pass $categories[0]->term_id?
This is my query so far…
$categories = get_the_category();
$years_query = "SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts AS p WHERE p.post_status = 'publish' AND p.post_type = 'post' ORDER BY p.post_date DESC"; $years = $wpdb->get_col($years_query);
Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Query distinct years in a category’ is closed to new replies.