wordpressで標準のウィジェットを使用してカテゴリー一覧のドロップダウンメニューを作成した後に任意の項目を非表示にしたい場合、/wp-includes/category-template.phpのfunction wp_dropdown_categories( $args = ” )に’exclude’ => ‘1,3083’,などとterm_idを指定すれば非表示にできる
$args = array(‘exclude’ => ‘3083,1’);$categories = get_categories($args);foreach ( $categories as $category ) {echo ” . esc_html( $category->name ) . ”;}で、カテゴリーに登録されている「プログラム自動修正」と「ja」カテゴリを非表示にすることができた
find . -type f | xargs grep -nE ‘option class=”.*”‘を実行しても出力がないのは、classがwordpress側で足されるのではなくて、テーマ側が足しているからかもしれない
find . -type f | xargs grep -E ‘select name=”.*” id=”.*” class’で、wordpressのドロップダウンメニューのselect要素がどのファイルにあるか調べることができた
wordpressのfunctions.phpで<?php wp_list_categories(); ?>で出力したhtmlには、class属性にcat-item cat-item-9501などのようにidが付与されていた