Created
March 3, 2016 11:56
-
-
Save gregoirenoyelle/21afa7a4d466bf9f77b6 to your computer and use it in GitHub Desktop.
Pre Get Posts Tests
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 // NE PAS METTRE CETTE BALISE | |
// A METTRE DANS VOTRE FICHIER functions.php | |
//* Ajouter le support de page pour les articles | |
add_post_type_support( 'post', 'page-attributes' ); | |
//* Changer ordre d'affichage dans les pages d'archives des articles | |
add_action( 'pre_get_posts', 'gn_post_archive_order' ); | |
function gn_post_archive_order( $query ) { | |
if ( $query->is_main_query() && !is_admin() && $query->is_category() || $query->is_tag() ) { | |
$query->set( 'orderby', 'menu_order' ); | |
$query->set('order','ASC'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment