I created this really simple function following the documentary of WordPress and as I understood it, this code should be working just fine
query_posts(array('orderby' => 'rand', 'post__not_in' => $_SESSION['watched'], 'showposts' => 1));
and the code for the session is no more advanced then this
if(!in_array($post->ID, $_SESSION['watched'])){
array_push($_SESSION['watched'],$post->ID);
}
If you know of any other solution or how to fix this specific one
all answers are very much appreciated… If I missed something out just tell me and I’ll add that information.
This topic on wordpress.org seems relevant to your question – there are obviously some rather weird issues with
post__not_in.Try this:
If that doesn’t help (which I actually suspect), the problem is clearly related to the post ids’ storage in the session.
Two things come to mind:
$_SESSIONbe populated after anything but headers has been sent? I don’t remember …Untested implementation as a plugin: