The only peice of code that I can find that applies to this is on line 2430 in query.php in WP 3.4.1
foreach ( get_post_stati() as $status ) {
if ( in_array( $status, $q_status ) ) {
if ( 'private' == $status )
$p_status[] = "$wpdb->posts.post_status = '$status'";
else
$r_status[] = "$wpdb->posts.post_status = '$status'";
}
}
From what I’ve experienced, with any other post_status
param added with the ‘private
‘ param added, the results will not be cross compared. For example, both (public) ‘publish
‘ and ‘private
‘ added, it will still return both publicly published posts and privately published posts. Here is a simple piece of code demonstrating it.
function example($post_status = array('publish'),
$excludeCurrent = 0)
{
$post_type_names = get_post_types('', 'names');
$skip_post_types = array('attachment', 'revision', 'nav_menu_item');
foreach ($skip_post_types as $value)
{
unset($post_type_names[$value]);
}
unset($value);
unset($skip_post_types);
$arg_query = array(
'post_type' => $post_type_names,
'post_status' => $post_status,
'post__not_in' => $excludeCurrent,
'nopaging' => TRUE,
'order' => 'date',
'orderby' => 'DESC',
'suppress_filters' => TRUE
);
$example_query = new WP_Query($arg_query);
return $example_query;
}
$example01 = example(); //returns only publicly published posts.
$example02 = example(array('publish', 'private')); //returns both publicly and privatly published posts.
$example03 = example(array('future', 'private')); //returns both publicly and privatly future posts as well as privatly published posts.
The third example is where my biggest issue is. After digging more before I posted this. I noticed that the operator ‘OR
‘ is always added between both post_status for the MySQL query. I also notice that the search param may offer a solution. So is there some additional filter that I may be missing? Possibly one to switch the MySQL operator ‘OR
‘ to ‘AND
‘?