I’m trying to get WordPress to not display certain posts but it still seems to display the posts that I’m telling it not to. I currently have this code:
<?php
if (have_posts()) : while (have_posts()) : the_post();
if (in_array($post->ID, $_SESSION['save_array_posts'])) continue;
?>
<div class="yl_bg_post main_content videos">
<h2 class="title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php the_content('<p class="more">More></p>'); ?>
</div>
<?php endwhile; endif; ?>
And I’m trying to make WordPress not display certain posts that are stored within $_SESSION['save_array_posts']
. The values are as follows:
array(5) { [0]=> int(190) [1]=> int(199) [2]=> int(63) [3]=> int(66) [4]=> int(68) }
WordPress seems to be looping through and still display them, I’m not quite sure why.
Not sure why you have this problem but you could try to exclude posts in the query like this and see if that solves your problem: