나는 여러 게시물을 동시에 게시 메타를 업데이 트하려고합니다. 나는 다음과 같은 쿼리를 가지고 :wordpress 여러 게시물을 게시 메타 게시
<form action="" method="post">
<?php
$variations = new WP_Query();
$variations->query(array('showposts' => -1, 'post_type' => 'product_variation')); while ($variations->have_posts()) : $variations->the_post(); ?>
<input name="regular_price[]" type="text" value="<?php echo get_post_meta(get_the_id(), "_regular_price", true); ?>" />
<input name="sale_price[]" type="text" value="<?php echo get_post_meta(get_the_id(), "_sale_price", true); ?>" />
<input name="item_id[]" type="hidden" value="<?php echo get_the_id(); ?>" />
<?php endwhile; wp_reset_query();?>
<input name="save" type="submit" />
그때 데이터를 처리하기 위해 다음과 같은 PHP가 : 위에서 제대로 저장하지 않습니다 어떤 이유로
<?php
if (isset($_POST['save'])) {
$ids = $_POST['item_id'];
$sales = $_POST['sale_price'];
foreach ($ids as $id){
update_post_meta($id,'_sale_price',$sale));
}
} ?>
합니다. 마지막 값만 저장하고 모든 게시물 메타에 적용합니다. 내가 뭘 잘못하고 있니?
@StreetCoder 왜 그런가요? – danyo
미안하지만, 나는 그것을 놓쳤다. 해결책을 찾고있다. – StreetCoder