Skip to content

Instantly share code, notes, and snippets.

@lorangr
Created March 11, 2016 11:26
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 lorangr/4c3f971fe7d0210ed7c6 to your computer and use it in GitHub Desktop.
Save lorangr/4c3f971fe7d0210ed7c6 to your computer and use it in GitHub Desktop.
Pre_get_post sort ACF and menu
<?php
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => __( 'Header Menu' ),
'extra-menu' => __( 'Extra Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
function my_pre_get_posts( $query ) {
// do not modify queries in the admin
if( is_admin() )
{
return $query;
}
// trier par date de deadline
else
{
$query->set('orderby', 'meta_value_num');
$query->set('meta_key', 'deadline');
$query->set('order', 'ASC');
}
// return
return $query;
}
add_action('pre_get_posts', 'my_pre_get_posts');
{
add_filter('widget_text', 'do_shortcode', 11);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment