Skip to content

Instantly share code, notes, and snippets.

@gregoirenoyelle
Created March 3, 2016 11:56
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 gregoirenoyelle/21afa7a4d466bf9f77b6 to your computer and use it in GitHub Desktop.
Save gregoirenoyelle/21afa7a4d466bf9f77b6 to your computer and use it in GitHub Desktop.
Pre Get Posts Tests
<?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