Th函数wp_set_object_terms()
无法设置后期对象属性。
添加/更新/删除产品简短描述there is mainly 2 ways:
(1)the WordPress way 来自post ID 使用wp_update_post()
功能如下:
$product_id = $post->ID; // or get_the_id() or $product->get_id() (when $product is available);
// The product short description (for testing)
$new_short_description = "<strong>Here</strong> is is the product short description content."
// Add/Update/delete the product short description
wp_update_post( array(\'ID\' => $product_id, \'post_excerpt\' => $new_short_description ) );
(2)
The WooCommerce way 从
WC_product
Object 使用
set_short_description()
:
// Optional: get the WC_product Object instance from the post ID
$product_id = $post->ID; // or get_the_id()
$product = wc_get_product( $product_id );
// The product short description (for testing)
$new_short_description = "<strong>Here</strong> is is the product short description content."
$product->set_short_description( $new_short_description ); // Add/Set the new short description
$product->save(); // Store changes in database
至
delete 您将设置的产品描述
empty string.
相关:How to programmatically grab the product description in WooCommerce?