我想在每个自定义类别中显示一个帖子(最旧的,但现在还不太重要),除了一个(称为“主页”)。
到目前为止我
1) 显示现有的每个自定义分类法段塞,我不需要的除外
2)显示特定分类法的所有自定义帖子(“肖像”)
如何执行脚本的第三部分也是主要部分-显示每个自定义分类法中的一篇文章?
//get all custom categories (taxonomy)
$terms = get_terms(array(\'taxonomy\' => \'album\', \'exclude\' => 4));
foreach ($terms as $term){
echo $term->slug;
echo "<br/>";
}
//get all custom post types of custom category "portraits"
//however, need to get one oldest post of each custom category from above
$args = array(
\'post_type\' => \'simple_image\',
\'posts_per_page\' => \'-1\',
\'order_by\' => \'date\',
\'order\' => \'ASC\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'album\',
\'field\' => \'slug\',
\'terms\' => \'portraits\'
)
)
);
$new_query = new WP_Query ($args);
while ( $new_query->have_posts() ) : $new_query->the_post();
the_post_thumbnail(\'thumbnail\') ;
endwhile;
这是一个照片库主题,我想显示一个带有缩略图的相册列表。缩略图将来自相册中的一篇帖子。[编辑]我看过一个脚本,其中WP query被放在foreach循环中,这对我来说没有多大意义。有更简单的吗?没有加入操作吗?