我有一個代碼,用cronjob定期更改元值。這個鱈魚不屬於wordpress。它只更新前8個產品。WordPress的查詢更新沒有更新所有文章
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'meta_key' => '_sale_price',
);
$the_query = new WP_Query($args);
while($the_query->have_posts()) : $the_query->the_post();
update_post_meta(get_the_ID(), "_regular_price", '$new_value');
endwhile;
如何更改所有後期元值?
謝謝您的回覆。它工作得很好。正如你所說的那樣,這僅僅是一個例子。但是當我挖掘該項目時,我發現我需要更多的查詢。我可以通過「$ data * _regular_price」更改此值,其中僅_sale_price = 10? –