How to Exclude Sticky Posts from the Loop in WordPress

Interactive Online > Blog  > CMS  > WordPress  > How to Exclude Sticky Posts from the Loop in WordPress

How to Exclude Sticky Posts from the Loop in WordPress

Sticky posts is one of the cool features that WordPress has, but sometimes you do not want to have sticky posts in your loop. In this article, we will show you how to completely exclude sticky posts from the loop in WordPress, and we will also show you how you can take away the sticky feature of the post, so it still shows in their natural order.

How to Exclude Sticky Posts from the Loop in WordPress is a post from: WPBeginner which is not allowed to be copied on other sites.

Related posts:

  1. How to Display the Latest Sticky Posts in WordPress
  2. How to Display Any Number of Posts in a WordPress Loop
  3. How to Make Sticky Posts in WordPress


Sticky posts is one of the cool features that WordPress has, but sometimes you do not want to have sticky posts in your loop. In this article, we will show you how to completely exclude sticky posts from the loop in WordPress, and we will also show you how you can take away the sticky feature of the post, so it still shows in their natural order.

How to take away the Sticky Ability of the Post

When you are displaying most recent posts in a tab, you do not want the sticky posts to stay sticky. If you do not remove the sticky features, the recent posts area would be useless as all of your sticky posts will crowd this area. This is when query_posts feature comes in handy.

To do this you will need to change your loop to something like this:

<?php
query_posts('caller_get_posts=1');
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>

Completely exclude Sticky posts from the Loop

If you are using Sticky posts in a slider, then sometimes you might want to completely exclude your sticky posts from the loop. All what you have to do is edit your custom loop to match with this:

<?php
query_posts(array("post__not_in" =>get_option("sticky_posts")));
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>

This code will not display any sticky posts in the post loop.

Source: WP Codex

How to Exclude Sticky Posts from the Loop in WordPress is a post from: WPBeginner which is not allowed to be copied on other sites.

Related posts:

  1. How to Display the Latest Sticky Posts in WordPress
  2. How to Display Any Number of Posts in a WordPress Loop
  3. How to Make Sticky Posts in WordPress

(read full article on source site)
Free Website for Your Dental Practice
See why our dental practice websites exceed the features & value of your typcial dentist website.
  • No cookie-cutter websites
  • No duplicate content
  • Custom built with a unique look and feel
  • Unique content written by professional writers
  • Set yourself apart from other dentists
  • The key to your online success!
* we never share your e-mail with third parties.