• Hello fnds,

    when I’m trying to use post__not_in with a variable it is not working.

    What I did is ‘post__not_in’=> array($posts_ids) but this wasn’t work. If i pass the post ids like this ‘post__not_in’=> array(55,56,60) it is working perfectly. otherwise it getting hide only first post and others still showing.

    i tried $postids[] = $post_ids;

    and ‘post__not_in’ => $postids; but it also not worked. pls help

Viewing 4 replies - 1 through 4 (of 4 total)
  • Just before the statement that has 'post__not_in'=> array($posts_ids), put

    <?php echo "<pre>"; print_r($post_ids); echo "</pre>"; ?>

    To see what is stored in that variable.

    Thread Starter Vinoj Randika

    (@patzz)

    when print $post_ids it display 59,63,170,45 and it hides only POST ID 59.. post 63,170 and 45 still showing.

    then what i did is create 5 separate variables and insert them in to an array like this

    ‘post__not_in’=> array($posts_id1,$posts_id2,$posts_id3,$posts_id4,$posts_id5) and give them above posts ids one by one for each and work perfectly.

    Why it dont work when i give those ids at once.

    Try

    'post__not_in'=> explode(',',$post_ids),

    I think you meant
    'post__not_in'=> implode(',',$post_ids),

    Unfortunately, that returns an error: argument should be an array

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘post__not_in not working’ is closed to new replies.