批量设置文章描述

以批量修改产品excerpt为例:

$all_products = get_posts( array(
'post_type' => 'product',
'product_cat' => 'torso-doll',
'numberposts' => -1,
'post_status' => 'publish',
'post_excerpt' => '[block id="us-descrition"]',

));
$i = 0;
foreach ($all_products as $products){
    if('[block id="us-descrition"]' == get_the_excerpt($products->ID)){
        $i++;
        wp_update_post(array(
              'ID'           => $products->ID,//the ID of the Post
              'post_excerpt' => '[block id="sex-doll-torso-description"]',
        ));

    }
}
echo $i;
© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享