I've registered a custom post type called "node".
When I create a basic WP_Query to get posts of that type, it works just fine. Example:
$args = array(
'post_status' => 'publish',
'post_type' => 'node');
$query = new WP_Query($args);
This will get all published posts of type "node".
However, as soon as I combine this with a search, nothing is returned. Example:
$args = array(
'post_status' => 'publish',
'post_type' => 'node',
's' => 'My search term');
$query = new WP_Query($args);
This will get nothing, although it should get several posts of type 'node' that contain 'My search term'.
As far as I can see, the post types are automatically set to "post" and "page" as soon as I include the "s" parameter in $args. If I print out a var_dump of $query, it shows the following:
Without "s":
object(WP_Query)
public 'query' =>
array (size=2)
'post_status' => string 'publish' (length=7)
'post_type' => string 'node' (length=4)
public 'query_vars' =>
array (size=63)
'post_status' => string 'publish' (length=7)
'post_type' => string 'node' (length=4)
...
With "s":
object(WP_Query)
public 'query' =>
array (size=2)
'post_status' => string 'publish' (length=7)
's' => string 'My search term' (length=14)
'post_type' => string 'node' (length=4)
public 'query_vars' =>
array (size=66)
'post_status' => string 'publish' (length=7)
's' => string 'My search term' (length=14)
'post_type' =>
array (size=2)
0 => string 'post' (length=4)
1 => string 'page' (length=4)
...
So Wordpress seems to override the post types as soon as a search is involved.
How can I fix that?