# 输出指定自定义分类法内容列表
> WordPress首页或其它页面需要调取指定自定义分类法内容列表时,可以使用以下方法:
> 通过while循环语句,设定指定自定义分类法名称、自定义分类目录名称、栏目ID、调取数目等参数,从而遍历出所需的数据
> 数据包括:文章链接、标题、摘要、内容、特色图像、发布日期(年月日)等
![](https://img.kancloud.cn/c3/67/c367880af0bb653c4150c4e73908de69_827x271.png)
```
<?php
$product_1_query = new WP_Query(
array(
'post_type' => 'showproduct', //自定义分类目录名称
'posts_per_page' => 8, //调用数目为8条
'tax_query' => array(
array(
'taxonomy' => 'product',//自定义分类法名称
'terms' => 19 //id为64的分类。也可是多个分类array(12,64)
),
)
)
);
if ( $product_1_query->have_posts() ):
while ( $product_1_query->have_posts() ) : $product_1_query->the_post(); ?>
<?php the_ID(); ?>
<?php the_title(); ?>
<?php the_permalink(); ?>
<a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>"><img src="<?php $post_ID=$post->ID;$post_thumbnail_id = get_post_thumbnail_id( $post_ID );$post_thumbnail_src = wp_get_attachment_image_src($post_thumbnail_id,'medium');echo $post_thumbnail_src[0]; ?>" alt="<?php the_title(); ?>"></a>
<p class="desc"><?php echo get_the_excerpt(); ?></p>
<?php the_time('Y-n-d'); ?>
<?php the_author(); ?>
规格:<?php echo get_post_meta($post->ID, '规格', true); ?>
<?php endwhile;
endif;
wp_reset_postdata();
?>
```