Get_posts not returning any posts when used with switch_to_blog

Question

I’m attempting to pull in some order information from the “shop_orderpost_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);
0
, , Alek Hartzog 2 years 2020-01-11T08:38:44-05:00 0 Answers 142 views 0

Leave an answer

Browse
Browse