Php 以编程方式创建的产品未显示在商店页面上

Php 以编程方式创建的产品未显示在商店页面上,php,mysql,wordpress,woocommerce,product,Php,Mysql,Wordpress,Woocommerce,Product,它显示在搜索下拉列表中,但不显示在商店页面上。所有这些产品细节都已完全保存在数据库中。有时,当我从管理面板更改了该产品的某些内容并将其保存时,它就可以正常工作了 $post = array( 'post_author' => $vendor_id, 'post_content' => str_replace(array("'", "\""), "", strip_tags($prod

它显示在搜索下拉列表中,但不显示在商店页面上。所有这些产品细节都已完全保存在数据库中。有时,当我从管理面板更改了该产品的某些内容并将其保存时,它就可以正常工作了

$post = array(
        'post_author' => $vendor_id,
        'post_content' => str_replace(array("'", "\""), "", strip_tags($product['description'])),
        'post_status' => "publish",
        'post_title' => $product['product_title'],
        'post_parent' => '',
        'post_type' => "product",
    );
update_post_meta( $post_id, '_downloadable', 'no');
update_post_meta( $post_id, '_virtual', 'no');
update_post_meta( $post_id, '_regular_price', $product['regular_price'] );
update_post_meta( $post_id, '_is_new', 'yes' );
update_post_meta( $post_id, '_sku', $product['product_id']);
update_post_meta( $post_id, '_price', $product['regular_price'] );
update_post_meta( $post_id, '_sold_individually', "yes" );
update_post_meta( $post_id, '_manage_stock', "yes" );
update_post_meta( $post_id, '_stock_status', wc_clean( $product['stock_status'] ) );
wp_set_post_terms( $post_id, 'outofstock', 'product_visibility', false );
update_post_meta( $post_id, '_backorders', "no" );
update_post_meta( $post_id, '_stock', $product['quantity'] );
update_post_meta( $post_id, '_ebay_user_id', $ebay_user_id );
update_post_meta( $post_id, '_download_limit', '-1');
update_post_meta( $post_id, '_download_expiry', '-1');
update_post_meta( $post_id, '_product_version', WC_VERSION );
wc_delete_product_transients( $post_id );

您的代码是部分的,不允许理解可能的原因。但是,您可能需要检查产品的可见性。如果设置为“搜索”(仅搜索结果),则应将其更改为“可见”(商店和搜索结果)。以下是一个例子: