我在这里撞到头了。虽然一篇文章有两个以上的类别似乎没有显示出来,但我似乎不知道这有什么错。这里怎么了?
<div class="base-column">
<button class="accordion">How To <img src="/wp-content/uploads/sites/2/2018/11/expand-button.jpg"></button>
<div class="panel">
<?php // How To
$args_1 = array(
\'post_type\' => \'post\',
\'category__and\' => array(117,123),
);
// The Query
$the_query_1 = new WP_Query( $args_1 ); ?>
<?php // The Loop
if ( $the_query_1->have_posts() ) {
while ( $the_query_1->have_posts() ) {
$the_query_1->the_post(); ?>
<strong>
<a class="title-article" href="<?php echo the_permalink(); ?>">
<?php echo get_the_title(); ?>
</a>
</strong><br>
<?php }
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
?>
</div>
</div>
SO网友:Colin
您需要编辑第7行。
\'category__and\' => array(117,123),
category\\uu和参数不使用类别ID的字符串。按如下方式编写数组:
\'category__and\' => array(
\'117\',
\'123\'
)
);