Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [update-post-meta]

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

1
vote
1answer
50 views

Change description on specific WooCommerce product status change

In WooCommerce, when I add couple of code lines to change the product description, on product status change, the website throw an error when submitting (saving). My code: add_action('...
1
vote
1answer
16 views

Is there a way to append meta data without creating a race condition?

Our site has a lengthy AJAX function that appends content to the user's cart, which is stored as an array in the usermeta table. The function looks something like this: $cart = get_user_meta($userID,...
1
vote
1answer
21 views

Update CPT post meta with update_post_meta and cron job

I'm attempting to regularly update a custom field ($company_rating) in a CPT with update_post_meta(). The cronjob is assigned and working. I've tested the function and it prints correctly (I've ...
1
vote
0answers
29 views

Custom Field Values not updating unless I click “Update” twice

I wanted to save custom field values to the revision history. The following URL had code that helped me achieve that (http://carolandrews.co.uk/saving-revisions-for-custom-post-type-meta-data/). The ...
0
votes
1answer
35 views

update_metadata() appends shortcode data for every page refresh

New to Wordpress. I have an implementation where I am writing multiple shortcodes on the admin panel and for every shortcode, I will update a post metadata key with every shortcode I find on the post....
1
vote
1answer
18 views

Show post updated date instead of published

I need simple solution to show updated date instead of published without adding any functions. I have read few articles, but they are bit complex using "dirty" code. This is my current code is it ...
0
votes
1answer
21 views

Automatically select template based on query string for New Posts

I'm looking to extend the concept found in Automatically select categories on new post based on GET value But instead of just setting a category during the new_to_auto-draft phase, a specific ...
0
votes
1answer
81 views

Update status, meta while inside a post using AJAX button

So I am trying to click a custom button I made in a meta box the fire off AJAX. All works except getting the ID of the post and the refreshing of the page. I have tried using global $post; $post_id = $...
0
votes
1answer
27 views

Add Array record to Meta Post

I am trying to add the following array into the meta post table "a:2:{s:11:"target";a:1:{i:0;a:1:{i:1;a:3:{s:5:"param";s:13:"page_selected";s:8:"operator";s:2:"==";s:5:"value";a:5:{i:3001;s:13:"...
0
votes
1answer
106 views

Save/update post_meta with Gutenberg from the panel

I've created a block, and I need to save as post_meta a value from an action on the panel. Php side: add_action( 'init', 'yasr_gutenberg_show_in_rest_overall_meta' ); function ...
0
votes
0answers
78 views

ACF (Advanced Custom Fields) not updating post or postmeta values

After changing the name of a ACF field, existing fields for some posts are not updating, but some are. Also, new posts are recorded correctly and can be updated. It's just that some of the old ones ...
0
votes
1answer
20 views

update_post_meta performance in a loop woocommerce

I have a simple question, I am working on the list order screen of woocommerce and want to add some buttons that via ajax will update some data to the database using update_post_meta. The issue is ...
0
votes
0answers
15 views

Save post meta save as multi dimensional array

I want to make portfolio page using meta field, where clicking to image opening image slideshows. So I want to loop main clickable image in array and images of slideshow as an array of main image, ...
0
votes
0answers
33 views

Unable to update the meta boxes with multiple fields

I successfully build a function, that is able to import data from a CSV into posts of a Custom Post Type (CPT). I am able to parse data into the native Title and Description fields, but it fails, when ...
0
votes
0answers
16 views

Editing post_meta from phpMyAdmin is not taking effect in the site

When I edit post meta value from database, it is still showing the old value on the front-end. Though, it shows my updated value in the edit post section, but in single.php it still shows the old one.
0
votes
0answers
225 views

Custom meta POST request fired twice when updating a post in Gutenberg

I have made a feature similar in behaviour to Revision Notes, but for Gutenberg. It is a Gutenberg sidebar plugin which adds a text field where users can write an edit summary when they edit a post, ...
1
vote
1answer
45 views

403 Error when text is pasted in Custom Metabox Textarea

I hope everyone is having a great day! I am creating this question as I have been stuck on this issue all day and I need some friendly advice. I have created a repeater custom metabox item for a ...
0
votes
1answer
40 views

How do you update post date (year only) in a separate custom field?

I would like to update all my posts with a custom field that stores the year the post was published. The "year" value will obviously be retrieved from the post's date meta data. I will then use the ...
1
vote
2answers
165 views

How to upload multiple image using wp_insert_post

Im using wp_insert_post to add products on the front end of a woocommerces site My current code will upload all the images but only the last image will be in the product gallery images heres my code;...
1
vote
3answers
473 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
442 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
146 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
22 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
23 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
228 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
184 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
238 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
71 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
37 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
113 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
53 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
18 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
53 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
181 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
219 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
128 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
171 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
1answer
76 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
24 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
216 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
34 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
851 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
104 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
73 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
1k 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
25 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
1answer
98 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
1answer
471 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
101 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 ...