Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

1
vote
3answers
147 views

update_post_meta() not working when used with WordPress action

I am trying to update the field when post status changes to published. It is getting the values properly but not updating when I check the what update field is returning. It shows some number. ...
0
votes
1answer
20 views

Does “update_post_meta” check if value is the same before updating?

When running the following code: update_post_meta( 1, '_visibility', 'visible' ); Does wordpress check to see if post_id 1 key _visable has a value of visible before writing to database? I have an ...
0
votes
2answers
26 views

WP cron and update post meta

I try to create a scheduled cron job which runs every hour, Its my first time working with wp-cron. In the cron function, I want to update post meta values, if some conditions are met. I also tested ...
1
vote
1answer
17 views

How do I set all of a particular post meta to a value within the custom post type I'm in?

I've currently got a custom checkbox that (if checked) sets a particular post as 'featured'. It also set all other posts as 'unfeatured', just before setting the current post. This has worked great, ...
0
votes
1answer
21 views

Add postmeta to all blog posts

I have a bunch of blog posts that I need to update with a custom postmeta key/value pair. Therefore I have two questions - where can I find the postmeta entries in a worpdress MySQL database and how ...
0
votes
1answer
38 views

Rename image filename using 'media_handle_upload'

I need to rename images uploaded by the user when they post on my site. I have a code that works perfectly to save the image and make it part of the post. But I want the images to be renamed to have ...
0
votes
1answer
64 views

Update meta_value in wp_postmeta using API

I am trying to update a specific meta_key field using an API. meta_key name is _yoast_seo_redirect. it contains a redirect URL which we give in post options within wordpress. What I am trying to ...
0
votes
1answer
69 views

update_post_meta() with a modified array?

When in wp-admin I want to manipulate one value of an array and then update the post_meta with this array. My array looks like this: 1285 array(1) { [0]=> array(2) { ["description"]=> ...
1
vote
0answers
38 views

update_post_meta saves nothing in database when run in publish_post

So I have a little function that runs successfully in with publish_post. This is the code: function socialOverlay( $ID, $post ) { $name = 'myname'; $email = 'myname@gmail.com'; $to[] = ...
0
votes
0answers
15 views

Programmatically create draft of existing post

Hi wordpress community, What I am trying to do is programmatically create an updated draft (not live) of a published post - so that the changes will be recorded but not published. Right now, my ...
0
votes
1answer
68 views

update_post_meta doesn't work

I've been drilling with codes for so long. I was trying to create a metabox with a simple textare on it. Been stuck for almost 10 hours tyring to solve this. Still up until right now my meta box ...
0
votes
1answer
28 views

Frontend form with multiple posts

I've been researching frontend post-editing/creating forms, but I can't seem to find anything about having multiple forms on the same page. Please excuse my shaky understanding of POST methods. Here ...
0
votes
1answer
15 views

How do I update a specific value within array in a products metadata?

Im trying to update a products meta information with values from a calculation. Back story is that we are selling parking spaces for an airport and the current system we have in place is that a ...
0
votes
0answers
47 views

When working with a post, almost all wp_postmeta are deleted

Almost all wp_postmeta removed after updating, deleting POSTS or editing ACF fields, messages what could be wrong? If you export SQL tables before and after, you will get this: u.p.d A request ...
0
votes
1answer
122 views

update_post_meta in loop changing ALL values

I have a button on the frontend that updates the value of post meta on the backend, and it's nested inside a loop. However, on submit it updates the value on ALL posts. What am I doing wrong? ...
0
votes
2answers
140 views

Updating post meta for checkbox

<div class="vp-field vp-checkbox vp-checked-field vp-meta-single" data-vp-type="vp-checkbox" id="_custom_meta[category][]"> <div class="label"> <label>Categories</label> &...
0
votes
0answers
35 views

Wordpress - update_post_meta won't save if empty?

Once I add any value into the field and trying to remove it it won't update until there is at least a one character (space). Is there any particular reason why wordpress won't save new value if empty ?...
0
votes
0answers
55 views

update meta data (like view counter) by rest-api

i want update view counter of post in app. i getting site data by rest-api to my app(created by ionic) ,but now i need update somethings like view counter that when a post viewed in app like site view ...
0
votes
1answer
79 views

wp_mail send email twice inside function updated_postmeta

I make a custom function so when postmeta updated to specific value i send custom email use wp_mail. email successfully send but it create twice at same time. here my code function ...
0
votes
0answers
45 views

Where am I going wrong acquiring the current post ID value in a function within functions.php

This is my code in functions.php - the only function herein ( 'the_some_meta_update' ) is trying to update the meta key 'license' of a certain custom post ( identified by $post_id ) with the post ID ...
0
votes
1answer
51 views

update_post_meta not working in foreach

To avoid adding post meta values one at a time (and reduce repeat code in my theme) I wrote a simple class to store all the options so I can iterate through. The class works fine and constructs an ...
0
votes
1answer
21 views

Updating my Post when expiry date is past

I have done some more reseach and come accross the following article which does exactly what I want it to do. According to the writer, the code works but when I try and adapt it to my circumstance it ...
0
votes
0answers
46 views

Im trying to supply the post ID to a plugin function in the plugin file. But instead of the value, its NULL

TY for opening my question! Im trying to update the meta key 'license' in a custom post that I have, with the ID of an existing WP post. So Im using a global variable to store the ID of the WP post ...
0
votes
0answers
35 views

Adding new field data is not saving into database in wordpress registration

I have been trying to add a field as password into wordpress registration form. It's showing in the database that specific user has password which is encrypted. But While I am trying to log in using ...
0
votes
0answers
143 views

update_post_meta() not updating

I'm saving API data as metabox data, and I'm attempting to update metabox data on import. So the Title, content data will always update. But I can't seem to be able to use the ID to update the metabox!...
0
votes
0answers
30 views

Update custom field on page specific to logged in user

I have a page that displays data specific to the user who has logged in--charts, etc. That works great. I have added a few custom fields on that page where I insert values using update_post_meta(). ...
1
vote
1answer
478 views

update_post_meta for custom field not working upon form submission

I have a custom field called _my_description The idea is when a form is submitted the data from the form is also put into this field. Here's my code add_action( 'gform_post_submission_10', '...
1
vote
1answer
86 views

Update postmeta Parent when post_status child change

I have custom status = completed. I want to set automatically when child post update status 'completed'. their parent's postmeta also change. here my code: add_action('save_post', '...
3
votes
1answer
60 views

Wordpress widget new instance creates content duplicates

I have a custom made widget that I wrote and I want to display two instances of the same widget in the same widget area. When I drag and drop new widget instance to the widget area inside admin panel ...
0
votes
2answers
2k views

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

How to save woocommerce product?

I need to import products from third-party API to woocommerce. How to save data using wp_insert_post()? name = string sku = string type = string regular_price = double description = string weight = ...
0
votes
1answer
17 views

Updating Lat and Lng of posts automatically gives sporadic results

I need to update the lat and lng meta fields for my posts automatically, based on the address entered from a CSV import. For some reason, the number of failed updates changes sometimes when I run my ...
0
votes
0answers
19 views

Mark posts that have been updated for two weeks

I run a website where users post mods and thus the posts get updated from time to time as the authors make changes to them. I would like to add an "Updated" mark to a post that has been updated. But ...
0
votes
0answers
86 views

Hook after post was created to update Custom Fields

I'm tryin to update post meta after a post was created but the get_post_meta function is not working. I have tried transitions, and almost every hook from documentation. The save_post_post , ...
0
votes
1answer
39 views

Set the value of custom field when post is published or updated

I'm trying to set the value of custom fields when a custom post type ('film') is published or updated. The end goal is to get meta-data from an API based on a URL field when the post is published or ...
0
votes
0answers
22 views

Posting to list item with OptionTree

Having a bit of an issue trying to get this to work. I am submitting a form which is entering data into meta fields of a custom post type, so I have wp_insert_post set up and working, entering text ...
0
votes
1answer
355 views

How trigger to save post when updating post meta

I have very confused situation. I have added posts and all posts metas from one website db to another one, everything is fine, images, title, description of posts are there. But post metas are not ...
2
votes
1answer
58 views

Why is variable value emptry in $_POST but available in $_REQUEST?

I'm trying to add a custom meta box to my theme by following the tutorial : https://www.sitepoint.com/adding-meta-boxes-post-types-wordpress/. I can see the meta box and It gets the value from ...
0
votes
1answer
22 views

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

update meta field value after

I am trying to update meta field value. Everything ok, problem is that field value does not showing in field after refreshing the page. For example, when I update name value then its does not show ...
1
vote
1answer
189 views

Assign category using custom field?

Is it possible to use a custom field to assign the post category? For example: I have Genres custom field to my custom post type Tvseries. Then i entered: Action, Drama, Comedy Once i save or ...
0
votes
0answers
292 views

How to debug 'update_post_meta' using AJAX to update a Custom Post Type from the front end

(This is a take 2, getting to grips with the Stackexchange formatting guidelines) I've successfully managed to create and update a CPT from the front end via a form. I need to do the same but now ...
1
vote
1answer
398 views

update_post_meta not working in save_post

I'm having an issue with a function i'm trying to create. It should be simple. When someone saves a post, grab the city/address/province and convert it to long/lat then save that to the database. The ...
0
votes
1answer
43 views

Custom meta box data not saving

I created this meta box for my custom theme. I thought I followed all the guidelines, but I'm hitting a wall. The meta box and all fields are showing, but when I update, the data is not saved. Meta ...
1
vote
1answer
292 views

update_post_meta for repeated custom field [closed]

I have a repeatable custom field made with "cmb2" plugin: $meta_box->add_field( array( 'name' => 'error', 'id' => '_pf_error_log', 'type' => 'text', 'repeatable' => true, ), ) ); ...
0
votes
1answer
459 views

update_post_meta not work [closed]

// Create tab add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' , 99 , 1 ); function add_my_custom_product_data_tab( $product_data_tabs ) { $product_data_tabs['my-...
0
votes
1answer
208 views

Create Meta boxes dynamically

I followed and created a meta box using all code from this question here: Create more Meta Boxes as needed Basically only two fields are created when you click on Add track button: Song title field ...
1
vote
0answers
204 views

Trying to update_post_meta function

I am trying to post saving using Post expirator and ACF the code was : // Schedule/Update Expiration $opts['expireType'] = 'draft'; $opts['id'] = $id; i am trying to change the $opts['...
0
votes
1answer
50 views

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

how to increase custom post value by one most efficiently?

I have a custom post type (created with cmb2) which always contains a number (can be zero as well). Some times i need to increase it by one with php, so i do this: $value = (int) get_post_meta($post-...