Ignore Sticky Posts on the Blog Page
Shows posts in plain date order on the blog page, even if some are marked "Stick to the top".
Opens WPIDE on
Code
add_action( 'pre_get_posts', function ( $query ) {
if ( ! is_admin() && $query->is_main_query() && $query->is_home() ) {
$query->set( 'ignore_sticky_posts', true );
}
} );
Notes
Blocks and widgets with their own sticky setting are not affected.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.