TMプリントのボディーで使用
フォーチ2回まわす。
その中でループ
<?php ///宣言------------------------------------------ $args = array( 'parent' => 0, 'hierarchical' => 0, 'orderby' => 'term_order', // Category Order and Taxonomy Terms Order を使用 'order' => 'ASC' ); $taxonomy_name = 'body_cat'; $taxonomys = get_terms($taxonomy_name,$args); if(!is_wp_error($taxonomys) && count($taxonomys)): foreach($taxonomys as $taxonomy_term):////フォーチ----------------------------?> <h3 class="body_title2" style="margin-bottom:30px;"><?php echo $taxonomy_term->name;?><span class="d_price"></span></h3> <?php $url = get_term_link($taxonomy_term->slug, $taxonomy_name); $taxonomy_term_childrens = get_term_children( $taxonomy_term->term_id, $taxonomy_name ); if(!is_wp_error($taxonomy_term_childrens) && count($taxonomy_term_childrens)): foreach($taxonomy_term_childrens as $taxonomy_term_children_id): $taxonomy_term_children = get_term_by('id',$taxonomy_term_children_id,$taxonomy_name); //echo $taxonomy_term_children_id ?> <h4 class="body_cat_child"> <?php echo $taxonomy_term_children->name; ?> </h4> <div class="body_box_all"> <?php $args = array( 'posts_per_page' => -1, //'orderby' => 'menu_order', //'order' => 'ASC', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => $taxonomy_name, 'field' => 'slug', 'terms' => array( $taxonomy_term_children->slug ), //'operator'=>'NOT IN' ), ), //カテ例 'cat'=> 4, //カテ複数例 'cat'=> array(4,6) ); ?> <?php query_posts( $args ); ?> <?php if ( have_posts () ) : while ( have_posts() ) : the_post(); ?> <?php include("roop_body.php"); ?> <?php endwhile; endif; ?> <?php wp_reset_query(); ?> </div> <!-----> <?php endforeach; endif; ?> <?php endforeach; endif; ?>