我有个问题。
<div class="list">
<?php
$categories = get_the_category();
$category_id = $categories[0]->cat_ID;
$args = array(
\'posts_per_page\' => -1,
\'offset\' => 0,
\'orderby\' => \'date\',
\'order\' => \'ASC\',
\'cat\' => $category_id
);
$products = get_posts( $args );
?>
<?php foreach ( $products as $post ) : setup_postdata( $post ); ?>
<div class="list__item">
<a href="<?php the_permalink(); ?>">
<figure>
<img src="<?php the_post_thumbnail_url(\'thumbnails--products\'); ?>" alt="">
</figure>
<h3><?php the_title(); ?></h3>
</a>
</div>
<?php endforeach; wp_reset_postdata(); ?>
</div>
如果我理解正确,现在我应该显示来自我当前所在类别的帖子,因为我正在检索她的ID,但会显示来自主要类别帖子的帖子。