Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个代码:
<?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”是行不通的。有任何想法吗?谢谢
试试这个:它在我的项目中工作。
<?php global $post; $args = array( 'numberposts' => 4, 'category' => '15,8'); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?>
谢谢。