php - Wordpress getting updated meta for multiple posts -


i working wp updating meta values.in codes here main function :

$get_post_ids = array(); $get_post_ids[] = $_request['ids'];  foreach ($get_post_ids $post_id) {   $meta_value = get_post_meta( $post_id, 'resturent_featured', true );   if( $meta_value == 'yes' ){      $new_value = update_post_meta( $post_id, 'resturent_featured', 'no' );   }else{      $new_value = update_post_meta( $post_id, 'resturent_featured', 'yes' );   } } 

its working when select 1 post.but not working when selecting multiple posts.

something might wrong here.if $get_post_ids[] array key , value comma separated must $_request['ids'] comma separated.then have use way:

$get_post_ids = $_request['ids']; $get_post_ids = explode(',', $get_post_ids); 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -