Parameter | Details |
---|---|
$query | (WP_Query) Loop object |
If you are using PHP 5.3.0 or above, you can use closures (anonymous functions)
add_action( 'pre_get_posts', function( $query ) {
if( !$query->is_main_query() || is_admin() ) return;
// this code will run only if
// - this query is main query
// - and this is not admin screen
});