我拼命地试图以编程方式获取与WooCommerce订阅对象相关联的帖子ID。我从用户标识开始,尝试使用get_posts函数请求数据库。使用get_users_subscriptions
的呼叫有效,但返回的对象不包括它们的ID
,仅包含关联的order_id
或product_id
。如何获得与Woocommerce订阅相关的帖子ID
$subscriptions = WC_Subscriptions_Manager::get_users_subscriptions(
$current_user->ID
);
$subscription_posts = get_posts(array(
'orderby' => 'date',
'order' => 'ASC',
'numberposts' => 1,
'meta_key' => '_customer_user',
'meta_value' => $current_user->ID,
'post_type' => 'shop_subscription'
));
get_post
请求可悲地返回一个空数组。我的请求中有错吗?
由于提前,