Created
April 21, 2011 21:15
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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