Last active
June 4, 2019 00:02
-
-
Save sinebeef/0e682f0a42ee7cd8ee8041ac8d802ed5 to your computer and use it in GitHub Desktop.
WP Modify pre_get_posts
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
/* Modify $query via pre_get_posts to change sorting | |
* of certain archive pages. | |
* @link https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts | |
*/ | |
add_action( 'pre_get_posts', 'custom_query_vars' ); | |
function custom_query_vars( $query ) { | |
if ( !is_admin() && $query->is_main_query() ) { | |
if ( is_product_category('cleats') ) { | |
$query->set( 'posts_per_page', '-1' ); | |
} | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment