• I’m currently using get_terms() to list all the terms within my “Event Regions” taxonomy. However, it only seems to list terms that are associated with published posts. How do I include the terms of future scheduled posts as well?

    My current code:

    echo '<ul>';
    
    $event_regions = get_terms( 'event-region' );
    
    foreach( $event_regions as $region ){
        echo '<li';
    
        if( $region->slug == get_query_var('term') ) {
    	echo ' class="current-cat"';
        }
    
        echo '><a href="' . get_term_link( $region ) . '">' . $region->name . '</a></li>';
    }

Viewing 1 replies (of 1 total)
  • Hi CoBu1,
    By default get_terms() excludes empty terms. So if the term (Region) only applies to an event that hasn’t been published yet, it won’t show.

    You need to set the “hide_empty” parameter to false, like this:

    $event_regions = get_terms( 'event-region', array(
        'hide_empty' => false,
    ) );
Viewing 1 replies (of 1 total)
  • The topic ‘Include terms of future posts when using get_terms()’ is closed to new replies.