如何在wordpress循环中显示来自一个类别或另一个类别的帖子?

如何在wordpress循环中显示来自一个类别或另一个类别的帖子?,wordpress,while-loop,wordpress-theming,categories,Wordpress,While Loop,Wordpress Theming,Categories,我试图创建一个wordpress循环,显示类别1或类别2的帖子。不必两者兼而有之。我现在所看到的只是两个类别的帖子。我已经在互联网上找遍了,但找不到我要找的东西 这是我的循环代码,目前仅显示分配给这两个类别的帖子 <?php // Example argument that defines three posts per page. $args = array( 'posts_per_page' => 3, 'cat' => 1, 'ca

我试图创建一个wordpress循环,显示类别1或类别2的帖子。不必两者兼而有之。我现在所看到的只是两个类别的帖子。我已经在互联网上找遍了,但找不到我要找的东西

这是我的循环代码,目前仅显示分配给这两个类别的帖子

     <?php 
// Example argument that defines three posts per page. 
$args = array( 
    'posts_per_page' => 3,
    'cat' => 1,
    'cat' => 154
); 
 
// Variable to call WP_Query. 
$the_query = new WP_Query( $args ); 
 
if ( $the_query->have_posts() ) : 
$i = 0;
    // Start the Loop 
    while ( $the_query->have_posts() ) : $the_query->the_post(); 
if ( $i == 0 ) :  ?>


//loop content here


<?php endif; 
    // End the Loop 
$i++;
    endwhile; 
else: 
// If no posts match this query, output this text. 
    _e( 'Sorry, no posts matched your criteria.', 'textdomain' ); 
endif; 
 
wp_reset_postdata(); 
?>

//在此循环内容

您是否尝试过在参数中使用category\uuuuu,如下所示:

    category__in => array(1, 154)

非常感谢。这就成功了,我没想到会这样尝试。谢谢你的帮助。