Hey, I’m trying to use ACF to to list a “featured” taxonomy term on a homepage. Basically, I’m looping through a custom taxonomy but only want to show those terms that have a true/false field checked. If this were a normal loop, it’d be easy but looping through the tax terms has complicated things. Any help? I’m having no luck elsewhere.
Here’s my code so far:
<?php // latest edition
$taxonomies = array(
'jjm_editions',
);
$args = array(
'meta_key' => 'feature_this_edition_on_homepage',
'meta_value' => '1',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'hide_empty' => false,
'number' => '1'
);
$terms = get_terms($taxonomies, $args);
foreach ( $terms as $term ) {
$term_link = get_term_link( $term );
if ( is_wp_error( $term_link ) ) {
continue;
}
echo '<a href="' . esc_url( $term_link ) . '" class="button">Latest Edition</a>';
} ?>