There’s a couple ways you could handle this.
Option 1 Check the global $post
object
Inside your filter you may be able to check the current $post
object or other Conditional Tags for a specific type.
function my_super_filer_function6( $args ) {
global $post;
/* Check against the current post object */
if( empty( $post ) || 'post_type_here' !== $post->post_type ) {
return $args;
}
/* Check conditional tags */
if( ! ( is_post_type_archive( 'post_type_here' ) || is_singular( 'post_type_here' ) ) ) {
return $args;
}
/* ... */
}
Option 2 Add the hook via template_redirect
or an early hook
You may be able to add the hook via an earlier action hook:
function wpse350295_init() {
if( is_post_type_archive( 'post_type_here' ) || is_singular( 'post_type_here' ) ) {
add_filter( 'listing/grid/posts-query-args', 'my_super_filer_function6' );
}
}
add_action( 'template_redirect', 'wpse350295_init' );
Option 3 Use the args
You may be able to check the passed args for a post_type
and return early if the post type does not match what is expected:
function my_super_filer_function6($query_args){
if( 'post_type' !== $query_args->get( 'post_type' ) ) {
return $query_args
}
/* ... */
}
This is of course assuming what is being passed is a WP_Query
object. You would need to do some due diligence to figure out what the passed variable holds and if a post type can be discerned from it.