How to get “last year from [spec year] that has posts”?
You could do a query for a single post made before the currently viewed year. When sorted by date in descending order (the default) the first result will be from the most recent year with posts. $current_year = get_query_var( ‘year’ ); $previous_posts = get_posts( array( ‘numberposts’ => 1, ‘date_query’ => array( ‘year’ => $current_year, ‘compare’ … Read more