How to disable sticky posts feature in WordPress. The best and most optimal solution is to simply “ignore” sticky posts on all queries which can be done with this code:
1 2 3 4 5 | add_filter( 'pre_get_posts', function( $query ) { if ( ! is_admin() && $query->is_main_query() ) { $query->set( 'ignore_sticky_posts', 1 ); } } ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.