Last active
January 2, 2016 12:19
-
-
Save salcode/8302846 to your computer and use it in GitHub Desktop.
Code to add to your functions.php to only display Sticky posts on your main blog page
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 the following code to your functions.php file | |
add_action( 'pre_get_posts', 'fe_pre_get_posts_sticky_only' ); | |
function fe_pre_get_posts_sticky_only( $query ) { | |
if ( | |
$query->is_main_query() | |
&& $query->is_home() | |
) { | |
$query->set( 'post__in', get_option('sticky_posts') ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment