Exclude Single Post in WordPress

50

Posted by: jzelazny on January 16, 2008

Categorized: HOWTOs, WordPress, WordPress Logic

Tagged: , , ,

If you would like to exclude one post from your blog, archive, search results or wherever you need to on your blog, you can do so by putting in a small piece of code within the particular WordPress loop:

The following example will show all posts except for the post with the ID of 179:

<?php if ( $post->ID == '179' ) continue;?>

This is something that I get a lot of requests for and is very useful in a number of situations.