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.

0
votes
1answer
16 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
28 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
23 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
35 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
22 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
0answers
10 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
14 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
29 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
15 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
102 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
36 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
38 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
86 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
344 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
268 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
90 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
181 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
138 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
195 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
52 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
28 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
90 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
46 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
16 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
158 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
190 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
49 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
104 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
135 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
49 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
69 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
23 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
48 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
45 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
199 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
31 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
717 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
101 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
67 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
997 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
22 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
105 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
72 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
25 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
430 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
93 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 ...