I have a unique use case that I can't seem to find an example for online. And it's possible I'm overthinking it.
I have a custom taxonomy called "grantees." When a blog post is created, the author can choose the grantee.
I have "browse by" pages so that these pages you can "Browse by grantee." This page lists all of the taxonomy of "grantees" and the number of posts associated with each grantee, using the following snippet of code inside of the WP Loop.
<ul class="list-terms">
<?php
$terms = get_terms(
array(
'taxonomy' => 'grantees',
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC'
)
);
foreach($terms as $term) {
?>
<li>
<a href="<?php $term_link = get_term_link( $term->term_id ); echo $term_link ;?>">
<?php echo $term->name ;?> (<?php echo $term->count; ?>)
</a>
</li>
<?php };?>
</ul>
This is working well. However, I need to now do this so that it pulls only a specific year (currently, 2018). I'm wanting to make archive pages based on year. My client uses this page as a way to keep track of blogs.
Is there a way to query just a specific year (say, 2018 posts), then have this page display the taxonomies associated with only the 2018 posts? I understand taxonomies don't have dates attached, but my thought is to query the 2018 posts, then ask WP to list the taxonomies of those queried posts.