I displayed all the posts in a page.
The selected post want to hide from the list.
Here is my code, and screenshot.
<?php
global $post;
if(is_category() || is_single()){
foreach(get_the_category() as $category){
$current = $category->cat_ID;
$current_name = $category->cat_name;
$myposts = get_posts(array('category__in' => array($current)));
$myposts = get_posts('numberposts=50&category='.$current);
}
}
foreach($myposts as $post) : setup_postdata($post);
?>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-3">
<div class="profile-desc">
<figure class="bgimg" style="background-image:url('<?php echo wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ); ?>');"></figure>
<div class="profile-heading"><?php the_title();?></div>
<div class="profile-history"><?php the_content(); ?>
<div class="read">
<a class="more-link" href="<?php the_permalink();?>"><?php _e('Read More');?></a>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
Screenshot
You will need to change your query. You can add
post_not_in
argument to it, so it will exclude it.It is much easier faster and safer then other approaches. Also it is the recommended approach by the WP codex:
http://codex.wordpress.org/Class_Reference/WP_Query#Parameters