カテゴリーのページに、概要を表示させる。
<?php echo category_description(); ?>
カテゴリーのページに、記事じゃなくて所属サブカテゴリーの一覧を任意のデザインで出す。
function.phpに
wp_list_categories2(パラメータは、wp_list_categoriesと同じ)を追加した。
function wp_list_categories2( $args = ” ) {$defaults = array(‘show_option_all’ => ”, ‘show_option_none’ => __(‘No categories’),‘orderby’ => ‘name’, ‘order’ => ‘ASC’,‘show_last_update’ => 0, ‘style’ => ‘list’,‘show_count’ => 0, ‘hide_empty’ => 1,‘use_desc_for_title’ => 1, ‘child_of’ => 0,‘feed’ => ”, ‘feed_type’ => ”,‘feed_image’ => ”, ‘exclude’ => ”,‘exclude_tree’ => ”, ‘current_category’ => 0,‘hierarchical’ => true, ‘title_li’ => __( ‘Categories’ ),‘echo’ => 1, ‘depth’ => 0,‘taxonomy’ => ‘category’);$r = wp_parse_args( $args, $defaults );if ( !isset( $r[‘pad_counts’] ) && $r[‘show_count’] && $r[‘hierarchical’] )$r[‘pad_counts’] = true;if ( isset( $r[‘show_date’] ) )$r[‘include_last_update_time’] = $r[‘show_date’];if ( true == $r[‘hierarchical’] ) {$r[‘exclude_tree’] = $r[‘exclude’];$r[‘exclude’] = ”;}if ( !isset( $r[‘class’] ) )$r[‘class’] = ( ‘category’ == $r[‘taxonomy’] ) ? ‘categories’ : $r[‘taxonomy’];extract( $r );if ( !taxonomy_exists($taxonomy) )return false;$categories = get_categories( $r );$output = “”;foreach($categories as $catearray){$cat_ID = $catearray -> cat_ID;$cat_name = $catearray -> cat_name;$category_description = $catearray -> category_description;$output .= “<li><h4><a href=’?cat=”.$cat_ID.”‘>”.$cat_name.”</a></h4><div>”.$category_description.”</div></li>”;}if ( $title_li && ‘list’ == $style )$output .= ‘</ul></li>’;$output = apply_filters( ‘wp_list_categories’, $output, $args );if ( $echo )echo $output;elsereturn $output;}function wp_list_categories2( $args = ” ) { $defaults = array( ‘show_option_all’ => ”, ‘show_option_none’ => __(‘No categories’), ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘show_last_update’ => 0, ‘style’ => ‘list’, ‘show_count’ => 0, ‘hide_empty’ => 1, ‘use_desc_for_title’ => 1, ‘child_of’ => 0, ‘feed’ => ”, ‘feed_type’ => ”, ‘feed_image’ => ”, ‘exclude’ => ”, ‘exclude_tree’ => ”, ‘current_category’ => 0, ‘hierarchical’ => true, ‘title_li’ => __( ‘Categories’ ), ‘echo’ => 1, ‘depth’ => 0, ‘taxonomy’ => ‘category’ );
$r = wp_parse_args( $args, $defaults );
if ( !isset( $r[‘pad_counts’] ) && $r[‘show_count’] && $r[‘hierarchical’] ) $r[‘pad_counts’] = true;
if ( isset( $r[‘show_date’] ) ) $r[‘include_last_update_time’] = $r[‘show_date’];
if ( true == $r[‘hierarchical’] ) { $r[‘exclude_tree’] = $r[‘exclude’]; $r[‘exclude’] = ”; }
if ( !isset( $r[‘class’] ) ) $r[‘class’] = ( ‘category’ == $r[‘taxonomy’] ) ? ‘categories’ : $r[‘taxonomy’];
extract( $r );
if ( !taxonomy_exists($taxonomy) ) return false;
$categories = get_categories( $r );
$output = “”;
foreach($categories as $catearray){$cat_ID = $catearray -> cat_ID; $cat_name = $catearray -> cat_name; $category_description = $catearray -> category_description;
$output .= “<li><h4><a href=’?cat=”.$cat_ID.”‘>”.$cat_name.”</a></h4><div>”.$category_description.”</div></li>”;
}
if ( $title_li && ‘list’ == $style ) $output .= ‘</ul></li>’;
$output = apply_filters( ‘wp_list_categories’, $output, $args );
if ( $echo ) echo $output; else return $output;}
要らないコードも入っているかもしれませんが・・・。
コメントを残す