A General Technology & Development Blog

Technology, Development, Programming – Magento, Wordpress.

Home » WordPress – How To Exclude Single Post From Query / Category / Loop

WordPress – How To Exclude Single Post From Query / Category / Loop

If you wish to exclude a single post from a WordPress query or category or archive or any other loop, you can do it by using the following code:


< ?php query_posts(array('category_name' => 'event-catering', 'posts_per_page' => 100, 'post__not_in' => array(321)));
if ( have_posts() ) : while ( have_posts() ) : the_post();
? >

Just change the category name, amount of posts you wish to show, and id of the post you want to exclude. In this example it is id 321.

Important Note: The code above has a *space* in between the starting tag and ending tag to get passed the page content conversion of this WP editor.

  • Was this Helpful ?
  • Yes   No

Name of author

Name: BlogOwner

Short Bio: "The master has failed more times than the beginner has even tried."

eXTReMe Tracker