archive-xxx.php
<div class="wrapper">
<?php
$args = array(
'parent' => 0,
'hierarhical' => 0,
'orderby' => 'id',
'order' =>'ASC'
);
$taxonomy_name = 'makerscat';
$taxonomys = get_terms($taxonomy_name,$args);
if(!is_wp_error($taxonomys) && count($taxonomys)):
foreach($taxonomys as $taxonomy):
$url = get_term_link($taxonomy->slug, $taxonomy_name);
$tax_posts = get_posts(array(
'post_type' => get_post_type(),
'posts_per_page' => 5,
'tax_query' => array(
array(
'taxonomy' => 'makerscat',
'terms' => array($taxonomy->slug),
'field' =>'slug',
'include_children' => true,
'operator' => 'IN'
),
'relation' =>'AND'
)
));
if($tax_posts):
?>
<h3 class="mincho"><?php echo($taxonomy->name); ?></h3>
<div class="fx-row fx-row-around-xs">
<?php foreach($tax_posts as $tax_post): setup_postdata($tax_post); ?>
<div class="fx-col-30-s fx-col-90-xs makerDiv">
<h4><?php if(has_post_thumbnail($tax_post->ID)) {
echo get_the_post_thumbnail($tax_post->ID,'post-thumbnail');
} ?></h4>
<!-- /.fx-row fx-row-around-xs -->
<h5><?php echo get_the_title($tax_post->ID); ?></h5>
<?php the_content(); ?>
</div>
<?php endforeach; ?>
</div>
<?php endif;
endforeach;
endif; ?>
</div>
<!-- /.wrapper -->
この一行超大事
<?php foreach($tax_posts as $tax_post): setup_postdata($tax_post); ?>
http://naoyu.net/wordpress/tax_query/583/
http://wpcos.com/?p=7846