Get_posts not returning any posts when used with switch_to_blog

I'm attempting to pull in some order information from the "shop_order" post_type.

This is on a multisite network, so I'm using switch_to_blog(1). When I set the post type as "post" it works great and I get the posts from the correct site. When I set the post_type to "shop_order" I get nothing, despite there being 20,000 'shop_order' records in the database.

switch_to_blog(1);
$args = array (
        //'post_type' = 'post',
        'post_type' = 'shop_order',
        'posts_per_page' = 2,
        );
$posts = get_posts( $args );
restore_current_blog();
var_dump($posts);

Topic switch-to-blog post-type get-posts Wordpress

Category Web


Per @Milo's comment:

probably post_status, which defaults to publish – Milo 53 mins ago

So I just set 'post_status' => 'wc_completed' in my args and I'm good.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.