How to alter local query, not main query [duplicate]

One of the easier ways to do this is to just add the filter before your query and remove it after:

add_filter( 'posts_orderby', 'filter_function' );

    $something = new WP_Query( $args );

remove_filter( 'posts_orderby', 'filter_function' );

Then you can just add your function into functions.php as normal:

/**
 * The below function filters something
 * Added inline on template blah.php
 */
function filter_function() {
    // Things n' stuff
}

You could also ( if you wanted to use pre_get_posts ) target not main queries:

if( ! $query->is_main_query() ) { /* ... */ }

Or as Milo suggests in an old answer – set a query var that your WP_Query will specifically use.