最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I exclude recent post from recent post php widget

programmeradmin6浏览0评论

I have this code, and I tried adding in post__not_in as suggested by another post I found on this website, and it didn't break anything but didn't work either. I also tried different examples.

Here's the php code I have

<?php 
$args = array( 'posts_per_page' => '4', 'post__not_in' => array($currentID) );
$recent_posts = new WP_Query($args);
while( $recent_posts->have_posts() ) :  
    $recent_posts->the_post() ?>
    <li>

        <?php if ( has_post_thumbnail() ) : ?>
            <?php the_post_thumbnail( $size, $attr ); ?>
        <?php endif ?> 

    </li>
<?php endwhile; ?>
<?php wp_reset_postdata(); # reset post data so that other queries/loops work ?> 

It doesn't get rid of the current post on the list

发布评论

评论列表(0)

  1. 暂无评论