Am rezolvat problema cu ajutorul lui Popescu Marian.
Solutia a fost inlocuirea liniei
$where = " WHERE post_type = '" . $post_type . "' AND post_status = 'publish' AND ID<>" . $id; // not the current post
cu
$where = " WHERE post_type = '" . $post_type . "' AND post_status = 'publish' AND (ID < ". $id ." OR ID > ". $id .") AND ID<>" . $id;
Plus schimbarea de mai inainte. @CristiG, am vrut in mod special aceasta sortare pentru ca se modifica densitatea foarte mult in pagina, datorita specificului site-ului.
In plus, la fiecare refresh, linkurile in pagina respectiva se modificau -> nu stiu cum vedea google toata treaba asta.
Multumesc pentru ajutor tuturor ! :)

