2

フィルタを含む製品ページがあります。カテゴリがない場合は、「カテゴリなし」のテキストを非表示にします。

<?php wp_list_categories(array('taxonomy' => 'products', 'orderby' => 'order', 'title_li' => '', 'child_of' => ($term->parent==0) ? $term->term_id : $term->parent)); ?>

どうすれば実装できますか?

4

1 に答える 1

1

引数配列に追加show_option_noneし、空の文字列に設定します。

<?php wp_list_categories(array('show_option_none' => '', 'taxonomy' => 'products', 'orderby' => 'order', 'title_li' => '', 'child_of' => ($term->parent==0) ? $term->term_id : $term->parent)); ?>


また、コードを少し書き直して、1行の長い行ではなく、デバッグが容易になるようにすることもできます。例:

<?php 

$args = array(
    'taxonomy' => 'products', 
    'orderby' => 'order', 
    'title_li' => '', 
    'child_of' => ( $term->parent == 0 ) ? $term->term_id : $term->parent
    'show_option_none' => '', 
);

wp_list_categories( $args ); 

?>
于 2012-10-31T14:08:13.687 に答える