get_posts() not working in functions.php

This is a bandaid, not a fix. But it seems there is a bug within WP_Query, so I had to modify the query right before it was actually run in order for the post_type parameter to not be ignored.

1) I changed get_posts() to a WP_Query

2) I added this to my functions.php file:

function ban_parse_wp_query( $query ) {
    $query->set( 'post_type', array('topic','reply') );
    return $query;
}

3) Then I modified the query with that action right before it was run and then remove the action right after so it would not affect any other queries:

add_filter( 'pre_get_posts', 'ban_parse_wp_query' );
$user_posts = new WP_Query($args);
remove_filter( 'pre_get_posts', 'ban_parse_wp_query' );

techhipbettruvabetnorabahisbahis forumuedusedueduedusedueduedusedusedusedus