Skip to content

Instantly share code, notes, and snippets.

@brycemcd
Created April 21, 2011 21:15
Show Gist options
  • Save brycemcd/935484 to your computer and use it in GitHub Desktop.
Save brycemcd/935484 to your computer and use it in GitHub Desktop.
some psuedo code to get you going on posts your users have already seen
<?php // the cookie should hold an array of post_ids ?>
<?php $seen_posts = unserialize( strip_tags( $_COOKIE["seen_posts"] ) ) ?>
<?php
// set up your WP "loop"
foreach $loop( "SELECT * FROM POSTS WHERE post_id NOT IN ( $seen_posts ) "): ?>
<?php
// you loop is empty. The SQL query returned no records
if( empty($loop) || count($loop) == 0 ){
$seen_posts = array();
// NOW start the loop again
}
?>
... looping code
<?php array_push( the_id, $seen_posts ) ?>
<?php endforeach; ?>
<?php setcookie( "seen_posts", serialize($seen_posts) )?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment