wordpressのカテゴリーをプルダウンで表示する際に、特定のカテゴリーを除外して表示したい
このサイトでプルダウンはできましたが、特定のカテゴリーを除外する方法がわかりません
https://star-webstudio.com/wpcate/
コードは以下です。
<?php $categories = get_categories(array('taxonomy' => 'category')); if ( $categories ) { $cat_selct = '<select name="cat-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;" class="post-catselect">'; $cat_selct .= '<option value="" selected="selected">カテゴリーを選択</option>'; foreach ( $categories as $category ) { $cat_selct .= '<option value="'.esc_html( get_category_link( $category->term_id ) ).'">'.esc_html( $category->name ).'</option>'; } $cat_selct .= '</select>'; echo $cat_selct; } ?>どなたか教えてください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/08 04:53