I want to create a list of posts from a Custom Post Type and add some filters the user can click to filter the list.
I added filters for all the categories by using the get_terms() function. Now I want to add filters by year, so I need a way to retrieve a list of all the years in which at least one post has been published...
I just need something like:
$years = get_all_years_with_posts();
// returns array( 2011, 2013, 2014 )
I know I can grab all the posts, check their year, and build the list myself, but is not there any other approach?