有没有办法更新post_content
包含特定product_tag
和产品属性。
$my_post = array(
\'post_content\' => \'New text\',
);
// Update the post into the database
wp_update_post( $my_post );
Update:我已经设置好了查询以获取我需要的帖子,现在我只需要正确地wp_update_post
$args = array (
\'post_type\' => \'product\',
\'post_status\' => \'publish\',
\'numberposts\' => 10,
\'product_tag\' => \'mug\', // CHANGE THE PRODUCT TAG
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'pa_chart-type\',
\'field\' => \'slug\',
\'terms\' => \'nautical\' // CHANGE THE CHART TYPE
)
),
);
$posts = get_posts($args);
print_r($posts);