For some use cases, couldn’t you use $query->get()
to target specific custom queries?
For example: say you’ve got a custom query for a slider
post-type. Perhaps something like this?
function wpse64950_filter_pre_get_posts( $query ) {
if ( ! is_main_query() ) {
if ( 'slider' == $query->get( 'post-type' ) ) {
// This is a query of slider posts,
// and isn't the main query;
// Do something
}
}
return;
}
add_filter( 'pre_get_posts', 'wpse64950_filter_pre_get_posts' );
Granted, this will target every such slider
post-type custom query; so it won’t work in every case. But it should work in some cases.