カスタム投稿タイプで設定したカテゴリ一覧ページを作成し、それぞれの親カテゴリーから子カテゴリーに階層を踏むようなページの作成をする場合
archive-カスタム投稿名.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<?php get_header(); ?> <!--****** /container ******--> <div id="container"> <div class="gNaviWrap"> <ul id="gNavi" class="list_style01"> <?php wp_list_categories(array('title_li' => '', 'taxonomy' => 'タクソノミー名')); ?> </ul> </div> <section> <?php //$paged = (int) get_query_var('paged'); $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array( 'posts_per_page' => 10, 'paged' => $paged, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'カスタム投稿名', 'post_status' => 'publish' ); $the_query = new WP_Query($args); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <span class="date"><time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time('Y.m.d'); ?></time></span> <h2 class="h2Style03"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p><?php the_excerpt(); ?></p> </div> <?php endwhile; endif; ?> </section> </div> <!--****** container/ ******--> <?php get_footer(); |
taxonomy-タクソノミー名.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<?php get_header(); ?> <section> <?php query_posts($query_string . "&pst_type=jiseki&posts_per_page=30&paged='.$paged"); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div> <?php $terms = get_the_terms( get_the_ID(), 'タクソノミー名' ); if ( !empty($terms) ) : if ( !is_wp_error($terms) ) : ?> <?php foreach( $terms as $term ) : ?> <span class="icon01 <?php echo "$term->slug"; ?>"><?php echo $term->name; ?></span> <?php endforeach; ?> <?php endif; endif; ?> <h2 class="h2Style03"><?php the_title(); ?></h2> <p><?php the_content(); ?></p> </div> <?php endwhile; endif; ?> </section> <?php get_footer(); ?> |
この二つのphpファイルを作成すれば大カテゴリーとカテゴリー別のアーカイブページが作成できます。
コメント