Created
October 16, 2015 13:33
-
-
Save TanvirAmi/1fb2aea46885760e352a to your computer and use it in GitHub Desktop.
Exclude posts from main wordpress loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'pre_get_posts', 'wpsites_remove_posts_from_home_page' ); | |
function wpsites_remove_posts_from_home_page( $query ) { | |
if( $query->is_main_query() && $query->is_home() ) { | |
$query->set( 'post__not_in', array(your_post_id) ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment