Articles of update post meta

Meta box data not saving

I have just started working with custom post types and meta fields/data. I’m able to get the custom post and meta field to appear. It just won’t save. I’ve been staring at the code and reading up endlessly but nothing has jogged for me what is wrong. I would love some fresh eyes on it […]

Reason action hook won't work with update_post_meta from frontend form? Alternative?

The code below works when I am inserting a post/using add_post_meta when submitting a form. The page refresh is flawless (see How can I fix a slow redirect after form submit from frontend (no plugin)?). However, I can’t seem to get the same effect when using forms that I intend to update the post meta […]

Update post meta using pending_to_publish hook

Below is my code for updating post meta. function changePostExpireDatetime( $post ){ $featurePlanID = get_post_meta($post->ID, ‘post_price_plan_id’, true ); remove_action(‘pending_to_publish’, ‘changePostExpireDatetime’, 10, 1); $plan_price = get_post_meta($featurePlanID, ‘plan_price’, true); update_post_meta($post->ID, ‘post_plan_price’, $plan_price ); update_post_meta($post->ID, ‘featured_post’, “1” ); add_action(‘pending_to_publish’, ‘changePostExpireDatetime’, 10, 1); } add_action(‘pending_to_publish’, ‘changePostExpireDatetime’, 10, 1); Function is called but meta is was not updated. How can […]

Change post date format to hebrew calendar

I’ve a wordpress site with Arabic language, it display the date of post using Gregorian calendar like this 24 فبراير 2016 in hebrew calendar it would be 24 شباط 2016 how can easily do this on any theme ??

WooCommerce Bookings Plugin Not Saving Order ID

I have built a site using WooCommerce Bookings with an AJAX request that processes the payment, creates and order and lastly creates a booking with the order ID. However, when I send the newly created order ID via the WooCommerce Bookings create method the order doesn’t appear in the Booking and I have to manually […]

Insert image into sub-field with update_post_meta

I found out that I could insert an image into a custom sub-field by just adding the image ID: update_post_meta($post_id, $metafield, 168); But that was a lucky guess – I didn’t see this info on the documentation for “update_post_meta”. But if I use this way, how do I specify the size of the image? And […]

Update post meta – Custom field does not match meta-key

I am trying to update my acf with update-post-meta: //ga_analytics_settings update_post_meta($my_post, ‘ganalytics_settings’, serialize($ganalytics_settings)); $ganalytics_settings is an array, which I would like to store serialized within the field. However, I get the following condition is not met(taken from meta.php): function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_value = ”) { global $wpdb; if ( ! $meta_type || ! […]

Save CTP post meta different values each day without overwriting previous values

I have a Custom Post Type which fetches some data every day for each post and I need to store new values while keeping the old ones. If I use this, it will overwrite previous data: update_post_meta(get_the_ID(), ‘temperature’, 25); update_post_meta(get_the_ID(), ‘humidity’, 70); update_post_meta(get_the_ID(), ‘ph’, 7); So I was thinking about using something like this to […]

Is it safe to add a new field to meta_value field?

I’m trying to offload WordPress images from my web server. I’ve successfully moved everything over to Amazon AWS and have a syncing mechanism in place that uploads new images to AWS. Now I would like to store a flag somewhere that indicates whether the image has been synced so my custom theme can pick the […]

Frontend Form Checkbox Update ACF Field

I’ve got a frontend form with text, select and checkbox inputs the text and selects update and work just fine, using update_post_meta() however the checkboxes aren’t updating. Since they’re stored in a serialized array do I need to use a different function or just set it up differently? update_post_meta($post_id, ‘appliances’, esc_attr(strip_tags($_POST[‘customMetaAppliances[]’]))); Here’s the code to […]