Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@roborourke
Created December 1, 2011 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roborourke/1418051 to your computer and use it in GitHub Desktop.
Save roborourke/1418051 to your computer and use it in GitHub Desktop.
Makes sticky posts in WordPress works out of the box everywhere
<?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