0

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);
3
  • probably post_status, which defaults to publish
    – Milo
    Mar 13 '16 at 15:49
  • Do not use $posts as local variable, rather use something like $posts_array Mar 13 '16 at 15:55
  • @milo, nailed it. If you want to post that as the answer so I can mark it as correct? Thanks man. Mar 13 '16 at 16:14
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.