Created
December 1, 2011 16:38
-
-
Save roborourke/1418051 to your computer and use it in GitHub Desktop.
Makes sticky posts in WordPress works out of the box everywhere
This file contains 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 | |
// stickier stickies | |
function fix_sticky_posts( $stickies ) { | |
foreach( $stickies as $sticky ) | |
wp_update_post( array( 'ID' => $sticky, 'menu_order' => -1 ) ); | |
return $stickies; | |
} | |
add_filter('pre_update_option_sticky_posts', 'fix_sticky_posts'); | |
function sticky_posts_query( $q ) { | |
if ( !isset( $q->query_vars['orderby'] ) ) | |
$q->query_vars['orderby'] = 'menu_order date'; | |
return $q; | |
} | |
add_action('pre_get_posts', 'sticky_posts_query'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment