How do I exclude recent post from recent post php widget

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&#

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744606009a4583469.html

相关推荐

  • How do I exclude recent post from recent post php widget

    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&#

    2天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信