Exclude three ID's from MySQL query

can anyone help with this query?

I have this default query below and need to EXCLUDE 3 IDs from results (5707, 5782, 5755) and i can't guess ho to add NOT IN inside this query structure. Please help!

        $agents_query = array(
            'post_type'      => 'agent',
            'posts_per_page' => $number_of_posts,
            'paged'          => $paged,
            'orderby'        => 'rand',
        );

        $agents_query        = inspiry_agents_sort_args( $agents_query );
        $agent_listing_query = new WP_Query( $agents_query );

1 answer

  • answered 2021-06-19 14:20 Claudio Xerez

    Solution:

            $agents_query = array(
                'post_type'      => 'agent',
                'post__not_in'   => array(5707,5782,5755),
                'posts_per_page' => $number_of_posts,
                'paged'          => $paged,
                'orderby'        => 'rand',
            );
    
            $agents_query        = inspiry_agents_sort_args( $agents_query );
            $agent_listing_query = new WP_Query( $agents_query );