我在循环中排除了一个类别(效果很好),现在我想在下面的这个循环中调用相同的类别。(这样它就会显示在页面底部。)我希望一双新的眼睛能帮助我告诉我这里发生了什么。它没有显示任何东西。我正在使用“新的 WP_Query”来引入单一类别......这里是:
<?php // Begin Recent Sold loop of 3 ?>
<?php $args = new WP_Query('cat=367'); // category 367
while($args->have_posts()) : $args->the_post(); ?>
<div class="category">
<h2 class="artist-name">
<?php echo '<a href="' . get_category_link( $category->cat_ID ) . '">' . $category->name . '</a> <a class="viewall" href="' . get_category_link( $category->cat_ID ) . '">VIEW ALL</a>'; ?></h2>
<ul class="subcats">
<?php
$cats = wp_list_categories('orderby=name&title_li=&use_desc_for_title=0&depth=1&echo=0&show_count=1&child_of='.$category->cat_ID);
if (!strpos($cats,'No categories') ){
echo $cats;
}
?>
</ul>
<div class="row clearfix">
<?php $query = array(
'post_type' => 'work',
'posts_per_page' => '3',
'orderby' => 'post_title',
'order' => 'ASC',
'cat' => $category->cat_ID,
);
query_posts($query);
if ( have_posts() ) while ( have_posts() ) : the_post();
$rows = get_field('images');
if(get_the_post_thumbnail()){
echo '<div class="four column work"><a href="'.get_permalink().'">';
echo get_the_post_thumbnail($post_id, 'medium');
echo '</a></div>';
} else {
if($rows)
{
foreach($rows as $row)
{
echo '<div class="four column work"><a href="'.get_permalink().'">';
echo '<img src="'. $row['image']['sizes']['medium'] . '" class="shadowed forced" alt="'.$row['image']['alt'].'">';
echo '</a></div>';
} ?>
<?php }
}
?>
<?php endwhile; wp_reset_query(); ?>
</div><!-- .row -->
</div><!-- .category -->
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
<?php // End Recent Sold loop ?>