The function update_post_meta() updates the value of an existing meta key (custom field) for the specified post.

learn more… | top users | synonyms

0
votes
1answer
495 views

change attachment custom field onChange event

The form is in post creating window. Ajax is posting values, but the values doenst renews. Where can be problem ? Ajax <script> function dynamic_Select(field, aid, value) { ...
1
vote
1answer
646 views

get_post_meta unserialize issue - retuns boolean(false)

I´m using a simple custom plugin that parses and saves external XML data as a serialized array in a custom field. This works fine, however, when I update the post, instead of the array I only see a ...
0
votes
1answer
22 views

Multicheck Selected Values Problem

I have a custom form using cmb2 plugin. User submit information which gets then stored on related Events Calendar Pro plugin fields. All works fine and gets stored fine but the selceted values of a ...
0
votes
0answers
15 views

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 ...
0
votes
2answers
35 views

Where does the actual data stored by add_post_meta

I am pretty new to WordPress API, loving it btw, I have a small project, adding a like button to the end of every post, pressing it makes user like the post, button changes to dislike, pressing again ...
1
vote
1answer
49 views

Best way to save postmeta

Just wondering what the best way to save postmeta is. I don't want empty postmeta values clogging up the database. I had already been saving postmeta in my plugin, which was adding empty values, so ...
0
votes
1answer
42 views

update_post_meta from data in multidimensional array created from a form

So, I have a few form fields like so: <input name='mainStageSatOrder[theband][theid]' type='hidden' class='band-id' value='' />"; <input name='mainStageSatOrder[theband][theorder]' ...
0
votes
0answers
30 views

ACF - Update User Meta Checkbox Values

I am using ACF and I have extended the user profile so it includes additional textboxes and checkbox values. On the frontend the user can update their user profile which is working as follows:- ...
0
votes
0answers
16 views

Attachment checkbox metabox will not update with update_post_meta

I've followed this tutorial for adding metaboxes to the attachment post type. The problem is that the metabox checkbox value is not updating to 'off' when it is unchecked and goes through the ...
0
votes
1answer
25 views

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 ...
1
vote
1answer
63 views

Update post meta does not serialize array

For some reason my update_post_meta() function does not accept an array. Normally the function serializes the array by itself, but now I need to do this by myself, otherwise it does not update. Could ...
0
votes
1answer
8 views

Custom Registration with Select and Upload function

I have a custom Registration form in my functions.php // Registration add_action('register_form','register_extra_fields'); function register_extra_fields(){ ?> <div ...
0
votes
1answer
24 views

Allow guest to update custom post met using ajax

I have a simple click counter that works using ajax, only problem is that if you're not logged in you can't update the counter meta box of the post. In my case the post it's an ad that when clicked ...
0
votes
0answers
11 views

Set all values of given meta_key in postmeta?

I have a custom post type to which I attached several fields of meta data. On a given action in the admin, I need to be able to reset the values of a specific meta_key in that meta data to zero for ...
0
votes
0answers
74 views

How to save data in wp_postmeta table in array form

I have two custom post type name episodes and courses . I want that I can linked the episodes to courses from the admin-panel . I was successfully in displaying the courses in episode section but ...
0
votes
1answer
115 views

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 ...
0
votes
0answers
37 views

Save the value of a wp_dropdown_pages

I have created a wp_dropdown_pages based upon the WordPress codex page global $post; $args = array( 'date_format' => get_option('date_format'), 'depth' => 0, ...
0
votes
2answers
58 views

Allow only one post with specific meta value

I'm using a custom meta field, to specify which post will appear as a featured one in the front page. This meta field is a true/false value, declared through ACF. I want this condition to only be ...
0
votes
0answers
46 views

WP_cron not updating post meta, instead clearing it

I'm trying to store social media follower count (ex. FB fans, Twitter followers) in post meta daily with wp_cron. If I manually save the post it will save the social media count numbers correctly in ...
1
vote
1answer
407 views

Making Wordpress author follow button, need missing ingredient

So i'm trying to make a follow button in wordpress where users can press a button that allows them to follow an author they like. (No, i'm not interested in buddypress) What i've done so far is use ...
0
votes
1answer
177 views

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 ); ...
0
votes
1answer
82 views

WP-API : post_meta not updated… but have another entry

When creating a post, I put some post_meta here is the code for the creation edition and deletion of a post https://gist.github.com/eduplessis/dc530523f0b98ae233dc and here is the result of the ...
0
votes
0answers
81 views

Post from front end form to post_meta

I want to save a value from the frontend of a post to the post_meta table. Sofar I have this, but it won't save...... I have read that I could use the update_post_meta even if the meta_key doesn't ...
0
votes
1answer
140 views

Update post_meta post_name with the post ID from wp_insert_post after user register

I'm creating a function that creates a page for a user when they register. The post created sits within a certain category. These are standard posts NOT custom post types. After the post is created I ...
-1
votes
2answers
123 views

Create custom field on post draft or publish?

How to automatically create custom field on post draft or publish with one of several offered values? For example I wish to create custom field named "random_color" with one of potential values: ...
0
votes
0answers
58 views

How to update post meta in schedule event action-function?

I want to execute something like this. What I must to change in following code? wp_schedule_event( time(), 'hourly', $string); add_action($string, 'do_this_hourly'); function do_this_hourly() { ...
0
votes
0answers
93 views

Unable to update_post_meta with data from wp_dropdown_pages

The pages are showing in the admin panel but I can't save them. When I select and update, it goes back to the first page in the list. I want to be able to save, so the admin can see the selected page ...
7
votes
1answer
12k views

How to save an array with one metakey in postmeta?

I have an array saved in postmata, each array key become a metakey. I want to change the code to save the whole array with one metakey. How to do that? Thanks! $poddata = Array( 'pod_id' => ...
0
votes
4answers
184 views

Remove href tag from wp_postmeta in 34,000 posts?

I'm using Godaddy Hosting, PHP 5, and Wordpress 4.2.1 I have 34,000 + posts that need outdated href tags removed. I am able to remove tags, one post at a time, by using this code in a page template ...
0
votes
0answers
20 views

Include timestamp in a foreach array

Please forgive me for my ignorance and thank you to anyone who helps. I have a follow/unfollow plugin that stores the respective user ids using update_post_meta. I am now doing a foreach loops to ...
1
vote
0answers
159 views

Update post meta using save_post hook in multisite

I am trying to update a post meta field in a custom post type in Multisite. i am using the save_post hook to do so unsuccessfully. I don't know if the reason / cause is the multisite? or wrong use of ...
1
vote
1answer
143 views

How to get update_post_meta output to include string length

I'm using the plugin WP All Import to import a special post type. The plugin includes an action hook pmxi_gallery_image that runs after the import that saves the attachment images to the post gallery. ...
0
votes
1answer
143 views

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 ...
0
votes
1answer
183 views

Post meta checkbox becomes unchecked occasionally

I removed the default author meta box on posts and added it back with a checkbox that I use to determine if a post should show the author's byline and author box. It's been working, but for some ...
0
votes
1answer
98 views

update_post_meta not working in function

I am attempting to take some custom field meta data (generated via the ACF plugin) and save it as post meta with a function. This is what I've come up with: function tps_create_slotcode($post_id) { ...
0
votes
1answer
73 views

Proper Way to Sanitize Meta Input

I have a meta field which gets displaed in the admin panel look like: $field = get_post_meta($postid, 'field_name', true); ?> <input type="text" name="field_name" value="<?php echo ...
2
votes
1answer
106 views

Efficient way to save a lot of meta data

im currently developing a plugin that will read an external xml, and convert the data to a custom post type. Each post needs around 50-60 meta_fields. Right now im looping through each piece of needed ...
0
votes
0answers
295 views

update_post_meta returning false when called during init

Given a custom URL like: http://clientsite.com/tvt?pmc_task=member_check&post_id=1041&user=3851&status=approved I'm trying to catch the URL and add the user_id to a custom post meta ...
2
votes
1answer
443 views

Unable to save datetime custom meta field using update_post_meta() function

When I do something like this (in my plugin function inside WP admin): $metaboxes = get_post_meta( $post_id ); echo "<pre>"; print_r($metaboxes); echo "</pre>"; die(); I get all my ...
0
votes
1answer
150 views

Programmatically set thumbnail via URL using DOM and XPATH - Where to add ELSEIF

EDIT3: I have gotten some outside help and have totally changed my code around to now use xpath to select the div instead of using the nth img from the html source. I am happy to say this is working! ...
0
votes
0answers
55 views

Performace on 1 million plus meta fields vs 1 field with 1 million multi array

We are potentially looking into building a counter in a post_type. So a post meta field wil be created with some data like total downloads and downloads left (tied to user ID). We expect up to one ...
0
votes
0answers
60 views

Trying to add $_POST Array to update_post_meta doesn't populate

This is the code that is sending the info: $postdata = array( 'show_id' => '11', 'show_start' => '2015-03-17 11:00am', 'line_items' => array( '1' => array( ...
0
votes
0answers
236 views

Problem with 'save_post' hook not running

I have a custom post type, with a custom meta box which contains a number of input fields. The meta box is displaying fine but when completing all the fields the data is not saving, in fact, the ...
0
votes
0answers
94 views

Insert post programmatically and decide to tweet or not to tweet

I am inserting a new post using wp_insert_post() and want to be able to decide if this post gets tweeted or not using the WP to Twitter plugin. First, I create the post, like so: $newpost = array( ...
0
votes
3answers
312 views

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 ...
0
votes
0answers
138 views

How To Get WordPress Categories Last Update Date?

I am trying to make a custom sitemap for my WordPress blogs categories. For that I added the below code in my functions.php file and save it. Now all things is working fine but I want to get the date ...
1
vote
2answers
3k views

Custom Post Type, Saving Multiple Checkboxes

For a custom post type, I'm pulling in a list of another custom post types that I need to select for saving ... <input type="checkbox" name="32"> My CPT <br> <input type="checkbox" ...
0
votes
1answer
191 views

Saving custom image meta fields

I have currently added a custom meta field for uploading a media file (image). I can successfully add the upload button to display and work but I'm having problems saving the field when updating the ...
-2
votes
2answers
90 views

Update an existing post in a custom post type

Lets say we have a connected user that access one of his post to replace some existing information in X fields that already exist with some new ones. How could I manage to update the old ones with ...
1
vote
1answer
227 views

Setting post meta data to random value during post status transition / on publish

Upon publishing an unpublished draft, I'd like the custom meta value "post views count" to be set to a random variable between 829 and 1013. I am using the code below, which doesn't always work. It ...