functions.phpに以下を記述
[php]if ( ! function_exists( 'post_is_in_descendant_category' ) ) {
function post_is_in_descendant_category( $cats, $_post = null ) {
foreach ( (array) $cats as $c…
以下の例では、カテゴリIDが30のカテゴリを親に持つ、子カテゴリ一覧を表示します。
<?php
$categories = get_terms( 'category', array(
'orderby' => 'count',
'hide_empty' => 0,
'child_of' => 30,
) );
foreach($categories as $value):
?>
<p><a href="<?php echo get_category_link($value->term_id); ?>"><?php echo $value->name;?></a></p>
<?php endforeach; ?>
graffiti on the web
この投稿へのコメント
コメントはまだありません。