Questions tagged [wp-update-post]

The tag has no usage guidance.

66 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
0 answers
9k views

wp_update_post does not update post_name

I have a post with id=1, post_title = 'Some post title' and slug(post_name)='some-post-title. I want to update its title and slug. $update_args = array( 'ID' => '1', 'post_title' => '...
Nikolai's user avatar
  • 31
2 votes
1 answer
2k 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 ...
Anna Gabrielyan's user avatar
2 votes
1 answer
188 views

How do I batch create revisions of all posts?

I cleaned up an old-site from pasted tags, manually created lists, etc, and I'd like to keep the old posts as "revisions", so we can easily "compare" with the old posts and retrieve/revert the ...
sergio's user avatar
  • 270
1 vote
0 answers
16 views

Changing Post Status from Pending to Publish twice daily

I have setup a function to change post status from Pending to Publish for posts in a specific category. The function works perfect if I run in under init, but doesn't work correctly if I run under a ...
jberg's user avatar
  • 11
1 vote
0 answers
39 views

How do I get my Gutenberg element to prevent last modified from updating?

I've added a checkbox on my Gutenberg post, that when checked, is supposed to prevent Gutenberg from updating the post's post_modified and post_modified_gmt columns. The checkbox manages its own state,...
John Doe's user avatar
  • 287
1 vote
1 answer
1k views

Update post / page using API + python

I'm trying to update posts using python and API, the issue that I keep getting code 200 but the post doesn't actually get updated! here is my code: import requests import json import base64 url ='...
Fadi's user avatar
  • 73
1 vote
0 answers
203 views

Allow Post Author to be 0 on Update

I have a custom post type that allows registered users to submit videos to my site. I have modified the script so that non-logged in (guest) users can also submit videos. I've added first-name, last-...
bowlerae's user avatar
  • 111
1 vote
0 answers
104 views

How to bulk edit image url in featured image and product description?

I have tried a few plugins (free) but none update the url in featured product image and product descriptions. How can I update in bulk instead of doing one by one? If there any any plugin (...
Organic Heart's user avatar
1 vote
1 answer
526 views

How to get the Tags on Publish post hook?

Requirement: On the each publish/update post, we need all tags from the post and do some functionality on that. Case 1: Create post, add tags and Publish immediately === WORKS PERFECT === Case 2: ...
Prashant Patil's user avatar
1 vote
0 answers
53 views

When User Meta amended update Title and Slug of Post programatically

I have this code below which works perfectly, i.e. when adding a new User a post is programatically created in my CPT. add_action( 'user_register', 'add_member_employees' ); function ...
Lindsay Heydon's user avatar
1 vote
0 answers
274 views

how to transition to custom post status on post save

I'm trying to add a custom post status "Needs Review" for posts/pages that have been updated by an editor, so that admins can easily see what has been updated and review the changes. The planned ...
Denise's user avatar
  • 11
1 vote
0 answers
173 views

why wp_update_post cant update when value is empty?

this runs successfully: wp_update_post( array('ID' => $postid, 'post_content_filtered' => 'something' ) ); but this doesnt update: wp_update_post( array('ID' => $postid, '...
T.Todua's user avatar
  • 5,789
1 vote
0 answers
479 views

update a post with wp_update_post

I am using a wp_update_post to change the status of a post from published to pending using wp_update_post( array( 'ID' => $post_id, 'post_status' => 'Pending', ) )...
MMTDesigner's user avatar
1 vote
0 answers
132 views

wp_update_post() blank screen

i am developing in functions.php a function which, when a post in a certain category is created/edited, will create also a related page or update it if already exists. The creation of a new page with ...
simonquasar's user avatar
1 vote
0 answers
5k views

Set Attachment Image File URL as GUID

I have a form that uploads images and i want to update the GUID to be the attachment file url after WP generates the metadata. I tried to use wp_update_post, but seems that is not updating the guid. ...
John Priestakos's user avatar
1 vote
0 answers
130 views

Set post_parent value for the images uploaded by Add Media button into post

I'm working on a front-end form plug-in and create shortcode to display front-end form on a page or post. While I was testing, I found all image files uploaded by Add Media button which will be ...
Ohsik's user avatar
  • 407
1 vote
0 answers
3k views

How can I bulk update all posts without making changes?

I'm setting up a site which uses a custom vehicle auction theme. Using the WP All Import plugin, an XML file loads vehicle details into the theme, these are a type of post. In order for vehicles to ...
Lucas Young's user avatar
1 vote
0 answers
173 views

Updating posts not working

Lets say I want to change a posts comment count to 50 everytime the post is viewed. I have this simple code in functions.php: function update_shares() { $my_post = array(); $my_post['ID'] = ...
pawelmysior's user avatar
1 vote
0 answers
958 views

Update a post's info when clicking on a javascript button

I have a series of posts about various locations. I need people to verify if the location informaton is correct. The question is asked with two buttons for options. If "no" is clicked, they are taken ...
Kenny Scott's user avatar
1 vote
0 answers
319 views

Post author for revision not being set on update/insert

I'm trying to programmatically update a custom-type post with revisions enabled via form, and everything seems to be working fine except the post_author field for the revision is being set to 0 ...
John's user avatar
  • 161
1 vote
0 answers
2k views

wp_update_post not working

I have the following code in a single script to be run one time to fix post names which are empty. // WP_Query arguments $args = array ( 'post_type' => 'books', 'name'...
Praz's user avatar
  • 70
1 vote
0 answers
285 views

Changing random post publish time for repost

I have a lot of image posts. So, on weekends I don't work for that I want to re-post a random post. I made my own code. It schedules random post with its permalink too. $time= strtotime("+10 min") ...
10wtaylor's user avatar
  • 315
0 votes
0 answers
18 views

wp_insert_post() function doesn't create posts after I deleted the first created Post by this function

I have wroted a function and hooked it to set_user_role action hook. here is my snippet: add_action( 'set_user_role', 'createTeacherPage', 10, 3); function createTeacherPage($user_id, $...
ata ashrafi's user avatar
0 votes
0 answers
20 views

Insert attributes names according to language with polylang programmatically

This is my problem. I try to insert in _product_attributes meta_value field the names of each language. When I print out my query, I am getting only the products in the right language, so ...
Rich's user avatar
  • 1
0 votes
0 answers
47 views

Trying to add a wp block and update the post content using PHP (wp_post_update)

I'm looking to write some PHP code that will be capable of looping through all of a certain custom post type and adding a specific block to the post_content, and then updating the post. For testing, I'...
Jordan K's user avatar
0 votes
0 answers
21 views

Updating post_parent caused the website to become unresponsive for 40 seconds or more

I am building a WordPress plugin the sets the post_parent of a post to the id of a custom post type called series. However, once I click update on the post it successfully updates the post and the ...
Petar Vasilev's user avatar
0 votes
1 answer
210 views

Set post status to draft after validating post meta values in save_post hook

I have some custom meta values to a custom post type ('event'). The custom post type is displayed in the admin and the custom meta fields are appearing fine. I am using save_post_{$post->post_type} ...
sariDon's user avatar
  • 265
0 votes
1 answer
78 views

Suitable hook when creating, updating and deleting posts programmatically

I am trying to create, update & delete posts programmatically from an API endpoint inside my plugin. My idea was to display these posts later on a dedicated page. Here's what I've written so far: ...
tearswep's user avatar
0 votes
1 answer
193 views

Trash Bin for Categories?

I have a cat_notice taxonomy, where there are several categories and one of them the slug is 'trash'. In this case I created a link and I needed that when I clicked on this link I would take the ...
Felipe Lenin's user avatar
0 votes
0 answers
296 views

Prevent other hooks from firing after wp_update_post() outside of editor

I'm working on a plugin that batch updates post content using a call to wp_update_post(). This all happens outside the editor window, in a batch processing script. My problem is that ACF is firing ...
Chris J Allen's user avatar
0 votes
0 answers
772 views

Set post publish date by custom field

I created custom fields with ACF to define a new date for my post on wordpress. I then created this function that updates the date with my custom field and works when I update a post. // Save ACF ...
Thompson1977's user avatar
0 votes
1 answer
147 views

Is it possible to "Update" pages via SQL?

How can I "update" a page in WordPress using MySQL? I.e., effectively click the "update" button in the page editor using MySQL? But not make any changes to the page? What I'm doing:...
BlueDogRanch's user avatar
0 votes
1 answer
368 views

Updating a custom post status after an expiry date rather than trashing it

I have set up a custom post type of featured products. Within that post type I have a custom date field for an expiry date. Currently when the date expires, the post gets moved to the Trash. I'm ...
Adam's user avatar
  • 111
0 votes
0 answers
349 views

Update post meta is slow while saving post

Post saving took much time. I have action to save custom metas using update_post_meta add_action( 'save_post_property', 'propertys_save' ); function propertys_save($id) { foreach($_POST['meta'] as ...
user2455079's user avatar
0 votes
0 answers
119 views

Run a function when a custom post is update?

There is a custom post type. Each post has a repeater field. When a post is updated, I need to get a value from the repeater field and insert it into a custom table in the WordPress database. To do ...
Sabbir33's user avatar
  • 103
0 votes
0 answers
153 views

Taxonomy Child Not Updating Unless I Click Update Twice

I am using code from this answer to create a new child taxonomy term, however for some reason the change only takes effect if I click update post twice. Clicking Update Post once doesn't save the ...
harvey's user avatar
  • 215
0 votes
0 answers
274 views

Cannot update newly added User field using wp_update_user

I want to add a new attribute to the wp_user table, "twitter_id" for example. I added the new column to the wp_user table, and it is added correctly. I get the current user (as I want to ...
DjangoBlockchain's user avatar
0 votes
0 answers
22 views

Update post "A" on comment submition on post "B"

Hello and thanks in advance for any help. Im trying to update the post status from a post when submiting a comment on other post, I have a variable in the url pointing to the ID of the post I want to ...
AHrtzt's user avatar
  • 13
0 votes
1 answer
341 views

wp_update_post gives 500 internal error

i'm editing a wordpress plugin and im trying to call a function within the thank you page, and in that function it has wp_update_post function to change the status in the database, the function works ...
omarhabeh's user avatar
0 votes
0 answers
159 views

update_post_meta not working in template_redirect action

I have a problem I'm trying to listen to a webhook, and I can do it, I check with the help wp_mail function and I get all the data But I want to make a add data in the database, and for some reason ...
Сергей Сокол's user avatar
0 votes
1 answer
732 views

wp_insert_post($post), add an array of values with update_post_meta

i try to store an array in multiple custom fields via post creation (wp_insert_post). The array is $event_test and the key is event_test on the meta_input. On form submit, the custom field is shown, ...
LovinQuaQua's user avatar
0 votes
1 answer
228 views

Change the term based on the value of a $variable using wp_update_post in submitting a form

Background I am using a fronted form to submit data to a meta box by use the wp_update_post to a custom post type (call) with a custom taxonomy (call-type). It then also updated the terms and ...
MFWebMaster's user avatar
0 votes
1 answer
466 views

Update post (published) date when changing category

Is there a way to update a post (published) date when you change the category/taxonomy to a specific one? Example: - Post type "Projects" - 2 categories: Progress/ Done When you change the category ...
Danny's user avatar
  • 13
0 votes
1 answer
1k views

How can I trigger a javascript function after a post update on edit post screen in wordpress admin panel?

I use Wordpress 5.2.2 and I develop a custom theme. EDIT : On my theme I added a metabox who show an input type="text". Code in functions.php of my theme if ( ! function_exists( 'vn_add_metabox' ) )...
Nouniz's user avatar
  • 17
0 votes
2 answers
2k views

Set a post expiration and delete a post when expirate

I'm trying to create a function that allows me to delete an article when the date of the day is equal or superior than a date filled in a custom ACF field. I wrote the function below that I placed in ...
willwoody's user avatar
0 votes
1 answer
164 views

Update all WordPress posts's title and content then display them in a table

I am trying to update all the WP post title and content then show the just updated post to a table. I am using the following code but it does not work: $args = array( 'post_type' => 'post', '...
David Nguyen's user avatar
0 votes
1 answer
81 views

Update around 200,000 posts

So I have recently migrated from a regular site to a wordpress CMS all via MySQL. I successfully was able to adapt the old database with that of WordPress. Now, the site has content in 3 languages. ...
Byte IT Antwerpen's user avatar
0 votes
0 answers
37 views

recursively update content

the problem I'm trying to translate a wordpress 4.7. But the site was consived in spanish and just now I installed the WPML plugin, now after 5000 post uploaded. I am using the visual composer and ...
ValRob's user avatar
  • 113
0 votes
1 answer
493 views

Bulk Post update_post_meta

how can use this code for update just post_meta ? here my code : function update_all_posts(){ $args = array('post_type'=> 'post', 'post_status' => 'publish', '...
Pedroxam's user avatar
0 votes
1 answer
109 views

Cannot update page - with too many characters?

I have problem with page update. I am tring to save more than 14230 characters. After "update" worpress is moving me to "Posts" page. I show this issue on this video: https://youtu.be/3Y8qgFEizBU ...
user3032346's user avatar