2013-10-15 90 views
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”不起作用。 任何想法? 谢谢

+0

使用'15,18':它会起作用,我已经在下面回答了。 –

回答

1

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

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

谢谢。

+1

它的工作原理。我以为我试过这个,但我做错了什么。谢谢。 –

+0

你总是欢迎! –