You don’t need your second foreach
loop.
foreach( $_POST['wt_set'] as $name => $val ){
update_post_meta( $post_id, $name, $val );
}
What’s happening is with your second foreach
is each entry is being processed individually and set as the post meta, so as it’s looping through it’s running update_post_meta( $post_id, $name, XXX );
then update_post_meta( $post_id, $name, XXX );
which overrides the previous one.
Related Posts:
- How to automatically apply woocommerce product title to all product images alt tags?
- Add custom field to attachments in a specific category
- How can update custom meta for all posts
- Passing the custom field values in the wp_get_current_user array function
- Firing schema via code in functions.php doesn’t work
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Trying to retrieve post meta
- Which PHP page is the Default Posts Page
- How to check if a PHP string is different than meta field?
- Can’t save php string to a custom field
- Why does this update_post_meta function not delete the custom field itself?
- How to show/hide php table rows based on the content of custom fields
- Custom meta box values are not getting saved for my custom post type
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- WP All Import / Update stock quantity from multiple XML files
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- How to add data to a custom field at the wp_users table?
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Hide a div when a custom field is empty
- Conditional On custom field plugin metabox
- Delete images from media library when user deletes an image from ACF Gallery
- Updating Metadata with Shortcode
- Products listing check if meta checkbox is checked
- Trying to update Woocommerce meta values
- Block error message in foreach loop when looping through ACF field
- Hide a div if the fiels is empty
- How do I get the value of a current user’s custom field?
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- Display custom meta box in my template file
- ACF Date fileds to Age Convert [closed]
- Appending an ACF custom field to the page title
- How to pass value to add_filter wpcf7_form_tag from another function?
- Custom Admin Menu Report for Specific User ID
- ACF number less than comparison not working
- start_lvl Ignored in Custom walker_nav_menu
- How do I make my function add variables/values to the $post object?
- Calculate percentage of post by category
- Change comments form title on a page by page basis
- Creating wordpress user registration form
- Get the title before comma
- category not display in word press grammatically
- “Can’t use function return value in write context” error
- Display 4 chronological posts starting with a random post
- my function doesn’t return my post from today
- Warning: array_pop() expects parameter 1 to be array, boolean given
- get_the_terms – only top level
- Have CSS Class Added with `is_page()` WP function
- Slide in Panel WordPress Post
- Run a filter when a walker runs
- comments_number display outside specified span
- Display fields as values in array from external SQL DB
- Populate dropdown with Child Pages based on Parent Page chosen
- How can I remove a function that has been added to wordpress with add_filter?
- Get value from shortcode to do something
- PHP 8, AJAX mail form to function.php doesn’t work
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- What’s the uses of wp_cache_set() or wp_cache_add()?
- auto-populating custom nav with all items from custom post type
- Can’t find infinite loop cause
- how to make custom ajax handler?
- How to disable controls in theme customizer?
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- Setting user nickname and displayname to shortened email
- Download PDF after CF7 form submission
- ::before on open/close function [closed]
- Creating a mobile site by adding a new class to the body tag from functions.php
- WP_Query: getting posts where custom field exists
- Export Form Data to a CSV then send it as an attachment – contact form 7
- Issue with fetching mysql data and displaying results via shortcode in webpage
- How do I create a function that modifies a message in the wp-login.php file?
- Cant display an image via PHP in wordpress
- Template Loop – add switch case php
- Show all tags within a category?
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- Unable to render custom field after attempt to generate a list of recent post in page template
- Unable to Call More than One Meta Box Output
- How can I alter this code to accept a slug as well as an ID?
- WordPress stripping out custom field tags
- How do you save the values from custom fields to a products data
- Adding an “Upgrade Subscription” button to an Elementor page
- Dropdown category field inside repeatable metabox
- Retrieve alt text by referencing the img src
- Custom function that re-writes page title breaks when the Yoast plugin is activated
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Edit a function to take different actions based on user role
- How to put 2 php codes in functions.php without site crashing
- wp_get_nav_menu_items() with ACF
- Unzip_file causing Media file upload error
- WP HTTP API call response
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Escaping a Single Quote in str_replace for Nav Function
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Custom fields changes the formatting of metabox input
- How can I put a custom field as the link of a button shortcode?
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- How can I create a menu items from meta box based on users input
- Fix My Custom Function: Remove Automatic
- WP Debug enabled Undefined index error in a widget
- Custom plugin doesn’t show in admin menu – when code added, displays an empty page