Remove sticky posts from main loop

/** * Remove sticky posts from main loop * @author Bill Erickson * @link https://www.billerickson.net/code/remove-sticky-posts-main-loop/ * * @param object $query */ function ea_remove_sticky_from_main_loop( $query ) { if( $query->is_main_query() && ! is_admin() ) { $query->set( 'ignore_sticky_posts', true ); } } add_action( 'pre_get_posts', 'ea_remove_sticky_from_main_loop' );
Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk