Mostrare termini di tassonomia vuoti con get_terms()
11 set 2014, 14:14:47
Visualizzazioni: 16.2K
Voti: 3
Ho una funzione impostata come segue:
<?php $terms = get_terms("wpsc_product_category");
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) { ?>
<li class="calendar-filter-menu-item" data-filter=".<?php echo $term->slug; ?>"><?php echo $term->count; ?></li>
<?php }
} ?>
Che mostra lo slug
e il count
per ogni tassonomia, l'unico problema è che non mostra le tassonomie che non hanno post assegnati, vengono visualizzate solo quelle con post assegnati. È possibile mostrare anche le tassonomie vuote?

user1374796
395
Tutte le risposte alla domanda
2
0
Puoi utilizzare l'argomento hide_empty
di get_terms()
. Il suo valore predefinito è impostato su true
.
Fallo in questo modo:
$args = array(
'hide_empty' => false
);
$terms = get_terms( 'wpsc_product_category', $args );

Nicolai Grossherr
18.9K
11 set 2014 14:27:38
Domande correlate
4
risposte