0

我有这个代码:

<?php
global $post;
$args = array( 'numberposts' => 4, 'category' => 15 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :  setup_postdata($post); ?>

问题是我想获取的不仅仅是类别号 15。只需将它们添加到 15 旁边,例如 15、18 或“15,18”是行不通的。有任何想法吗?谢谢

4

1 回答 1

1

试试这个:它在我的项目中工作。

<?php
global $post;
$args = array( 'numberposts' => 4, 'category' => '15,8');
$myposts = get_posts( $args );
foreach( $myposts as $post ) :  setup_postdata($post); ?>

谢谢。

于 2013-10-15T05:58:42.310 回答