This file contains hidden or 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 | |
add_filter('posts_orderby', 'blog_change_sort', 10, 2); | |
function blog_change_sort( $orderby, $query ) { | |
// Only modify main query | |
// On the tutorial category page | |
if( $query->is_main_query() && is_category('tutorials') ) { | |
return "post_title ASC"; |
This file contains hidden or 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 | |
add_action('pre_get_posts', 'blog_change_sort'); | |
function blog_change_sort( $query ) { | |
// Only modify main query | |
// On the tutorial category page | |
if( $query->is_main_query() && is_category('tutorials') ) { | |
$query->set('orderby', 'title'); |
This file contains hidden or 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 | |
add_filter( 'posts_request', 'show_posts_request' ); | |
function show_posts_request( $request ) { | |
echo $request; | |
return $request; | |
} | |
?> |
This file contains hidden or 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 | |
add_action( 'pre_get_posts', 'blog_exclude_cat' ); | |
function blog_exclude_cat( $query ) { | |
// Only modify the main query | |
// On the home page | |
if( $query->is_main_query() && $query->is_home() ) { | |
$query->set( 'cat', '-8' ); |