芝麻web文件管理V1.00
编辑当前文件:/home/r5772835/public_html/rigato2.ycreate.site/wp-content/themes/swell/lib/pluggable.php
term_id ) { return $the_cat; } } } } // 一番親を返すか、子を返すか $p_or_c = SWELL::get_setting( 'pl_cat_target' ); if ( 'parent' === $p_or_c ) { $_cat = null; $_acts_ct = 0; foreach ( $categories as $the_cat ) { // 一番親のカテゴリーであればすぐにそれを返す if ( 0 === $the_cat->parent ) { return $the_cat; } $ancestors = get_ancestors( $the_cat->term_id, 'category' ); // 親カテゴリー自身と紐付いてなくても親のカテゴリー名で表示する // if ( 1 ) { // return get_category( $ancestors[ count( $ancestors ) - 1 ] ); // } // まだ1度もセットされていない時はまず記憶させる if ( 0 === $_acts_ct ) { $_cat = $the_cat; $_acts_ct = count( $ancestors ); continue; } // 親の数がより少なければ上書き if ( $_acts_ct > count( $ancestors ) ) { $_cat = $the_cat; } } return $_cat; } elseif ( 'child' === $p_or_c ) { $_cat = null; $_acts_ct = 0; foreach ( $categories as $the_cat ) { $ancestors = get_ancestors( $the_cat->term_id, 'category' ); // まだ1度もセットされていない時はまず記憶させる if ( 0 === $_acts_ct ) { $_cat = $the_cat; $_acts_ct = count( $ancestors ); continue; } // 親の数がより「多ければ」上書き if ( $_acts_ct < count( $ancestors ) ) { $_cat = $the_cat; } } return $_cat; } // 特に条件のヒットがなければ最初のカテゴリーを返す return $categories[0]; } endif;