• Skip to primary navigation
  • Skip to main content
  • Skip to footer

TECHXT

simple extendable solutions

  • Home
  • WordPress Tutorial
  • SEO
  • How to
  • Forum
  • Knowledge Base
    • Domain Name Generator
    • My Tech Projects
    • News
    • Security
  • About
  • Search
Home › Featured › How to ignore sticky posts in WordPress homepage loop
Image
Featured, Wordpress Tutorial

How to ignore sticky posts in WordPress homepage loop

By Sudipto

0

Image

Sticky posts acts as featured posts that sticks at the top of all posts no matter when they have been published. Most themes these days have there own way of displaying featured posts. May it be in the form of a slider on the top or just a list widget in the sidebar. Normally most themes take care that if they have an option to display featured posts on the home page then they do remove the sticky posts from the homepage posts loop. But when I say most themes then it definitely does not mean all themes. So if your theme is showing sticky post and you want to get rid of them then just include the below code in the functions.php file of your theme–

Remove sticky posts from home page

add_action( 'pre_get_posts', 'xt_ignore_sticky' );

function xt_ignore_sticky( $query ) {
    if ($query->is_main_query() && $query->is_home()) 
    {
        $query->set( 'ignore_sticky_posts', 1 );
    }
}

Remove sticky posts from everywhere

The above code will remove sticky posts from your homepage. If you would like to remove sticky posts from everywhere then add the below code–

add_action( 'pre_get_posts', 'xt_ignore_sticky' );

function xt_ignore_sticky( $query ) {
    if ($query->is_main_query()) 
    {
        $query->set( 'ignore_sticky_posts', 1 );
    }
}

P.S. – Incorrectly modifying PHP code can break your site, so please be careful while doing so.

I am the founder and developer at TECHXT. Over the decade I have helped hundreds build their own site. All plugins I develop are made have a common goal: Make it as simple as possible and as easy to use as possible.
Image
Sudipto
View all posts by Sudipto
Sudipto's Website / Google+

Do you like this article?

sticky posts
Image

About Sudipto

I am the founder and developer at TECHXT. Over the decade I have helped hundreds build their own site. All plugins I develop are made have a common goal: Make it as simple as possible and as easy to use as possible.

Follow me

Footer

Subscribe by email

FOLLOW US : Image Image

Tools & Apps

  • Domain Names Generator
  • Our Wordpress Plugins
  • HTML Code Table

TechXT Network

  • www.seecoupons.com – Just another Deals & Coupons site
  • pincodes.techxt.com – A search engine for Indian Pincode.
  • stdcode.techxt.com – A search engine for Indian STD Codes
  • mobileinfo.techxt.com – A search engine for Indian Mobile Codes
  • bankifsccode.techxt.com – A search engine for Indian Bank IFSC Codes.

Info

  • Contact us
  • Privacy Policy
  • Image
      simple extendable solutions

© Copyright 2025 TECHXT.COM

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.
Advertisement