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

learn more… | top users | synonyms

1
vote
2answers
27 views

post meta getting deleted on save

I'm having an issue saving post meta on all post types, both default and custom. I'm hooking in to save_post to run my function, and what's happening is that the post meta gets added, but then ...
2
votes
1answer
21 views

How to update single value in multi dimensional Post Meta?

There are some values in Post Meta Data stored as a multi dimensional array. I want to update some of their data. Here is the Post Meta value displayed using <?php the_meta(); ?> voter: a:1:{s:...
1
vote
0answers
23 views

Button inside Custom Meta Box triggering the Update Button

I have a custom meta button that adds additional custom meta fields inside the custom meta box. This meta box, in particular, gives me a choice to enter a particular skill and rate my own ...
0
votes
1answer
21 views

add_post_meta doesn't work

I tried this on localhost and it worked, but then I tried to run this on live server (the same template, everything) and it doesn't work. Any help? add_post_meta('39', 'overall', '4');
0
votes
1answer
26 views

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

Update attachment metadata fails

Updating attachment title and description metadata with wp_ajax breaks all previous datas and structure of attachment, my php code: add_action( 'wp_ajax_update_attachment', '...
0
votes
1answer
26 views

Get original post ID after wp_insert_post

I have a plugin with several CPTs (we'll call them CPT-A, CPT-B, CPT-C, and CPT-D). All CPTs have custom fields. In CPT-D, the user is able to make a selection and assign a post in CPT-A, CPT-B, and ...
4
votes
1answer
79 views

Check if user already visited this post today

I have a piece of code which measures a post popularity. How would I go about checking if user didn't already visited this post for past 24 hours? Do I need to set a cookie for user and for each post ...
4
votes
2answers
111 views

esc before saving or before displaying does it matter?

In a lot of how to create a custom meta box tutorials, when saving data, i.e., update_post_meta the data is escaped: update_post_meta( $post_id, 'city', esc_attr( ucwords( $_POST['city'] ) ) ); ...
1
vote
2answers
15 views

Add a meta value if admin , editor or any other user have open a post in edit mode

In my application user can publish a custom post from front end . And later admin or capable user can update or delete the post . What I want to do , is to determine if that post is seen by admin or ...
0
votes
0answers
31 views

Clone a Post Title and Custom Field to a CPT

I am using Simple Urls Plugin to setup redirects on my blog. I am trying to create redirects automatically upon publishing a post. For example, If i publish a post about StudioPress it will be ...
0
votes
1answer
25 views

Saved Post Meta Array Returns as String

I am saving an array in post meta using update_post_meta. $arr = array('this', 'or that'); update_post_meta($post_id, 'field', $arr); $ret_arr = get_post_meta($post_id, 'field', true); var_dump($...
0
votes
1answer
96 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
57 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
73 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
99 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]' type='...
0
votes
0answers
83 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
35 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
35 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 ...
0
votes
1answer
11 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 class=...
1
vote
1answer
150 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
36 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
23 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
107 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 don'...
0
votes
1answer
212 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
47 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
71 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
67 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 ...
0
votes
1answer
243 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 ); remove_action('pending_to_publish',...
0
votes
0answers
98 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
215 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 ...
0
votes
0answers
76 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
125 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 ...
0
votes
4answers
203 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 ...
1
vote
0answers
200 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 ...
0
votes
1answer
87 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 ...
1
vote
1answer
176 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
158 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 plugin)?)...
0
votes
1answer
244 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
120 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
83 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 (!empty($...
0
votes
0answers
355 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 ...
0
votes
1answer
165 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
60 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
62 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
294 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 ...
2
votes
1answer
118 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 ...
1
vote
1answer
442 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
0answers
103 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
407 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 ...