我试图得到两个最近的职位,但我想排除其ID[365]特定职位。有人能帮我吗?这里是我的代码。
$args = array( 'numberposts' => '2' , 'post__not_in' => array( '365' ) );
$recent_posts = wp_get_recent_posts( $args );
<?php foreach($recent_posts as $post):?>
<a href="<?php echo $post['guid']?>"><p><?php echo $post['post_title'];?></p></a>
<?php endforeach;?>
3条答案
按热度按时间ljo96ir51#
只需将您的代码替换为下面提到的代码,您将得到您想要的结果:
djp7away2#
您应该再次为该函数使用read the docs。您有一个可用的
exclude
参数:vnjpjtjt3#
wp_get_recent_posts不支持
post__not_in
参数,您将需要使用exclude
wp_get_recent_posts的参考链接