Avoid Current Post from Recent Posts List

edited November 2022 in Wordpress

I want to get all recent post list but not that post which is opened
This is My Code :

get_posts( array(
        'posts_per_page' => 10, 
        'post_type' => 'post',
         'orderby'   => 'post_date',
         'order' => 'DESC'


  • Add post__not_in in your array :

    $post = get_post();
    get_posts(  array(
                    'post__not_in' => array( $post->ID ),
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!