Questions tagged [wp-update-post]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Bulk update published posts date randomly using wp-cli?

I see an option ([--post_date=<post_date>]) in wp-cli, but how can we use wp-cli to update all my published posts date randomly? For example, I want all posts date changed randomly between 01-01-...
user avatar
  • 1
0 votes
0 answers
12 views

Autopopulate a value

I created an options page where users can enter their Google Captcha key and secret. Using update_option I am able to add these values to Elementor's settings. I'm trying to do the same with JetForm ...
user avatar
  • 3
0 votes
0 answers
30 views

remove_action('save_post') in function that was triggered by save post not working

The goal Update post title and slug on successful insertion into post table without re-triggering the save_post hook. Current behavior The function as it is, still triggers the save_post hook, even ...
user avatar
0 votes
1 answer
60 views

$wpdb->update() always need a second try

I will use a custom endpoint of REST APi to update fields in a custom table. Therefore, i wrote this function: function update_table_single($request = null){ global $wpdb; $data_key = trim($...
user avatar
  • 103
0 votes
0 answers
55 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 ...
user avatar
0 votes
0 answers
91 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 ...
user avatar
0 votes
0 answers
38 views

update post status with cron

Hi I am trying to update the status of a woocommerce order this is what I have at the moment I know the field content matches and if I write this as DB query and run it in phpmyadmin it works can ...
user avatar
0 votes
1 answer
50 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:...
user avatar
-1 votes
2 answers
564 views

wp_update_post does not change post status from draft to publish, returns 1

I'm writing a post approval utility for the front end, because we don't want our editor to be able to access the admin dashboard. There are questions on Stack nearly identical to what I'm trying to ...
user avatar
  • 117
0 votes
1 answer
44 views

Why does wp_update_post causes white screen?

I made a custom post type, named "Foglalás". Each post in the Foglalás post type has neither title nor permalink. All of them are kind of Auto Draft after saving. So, I would like to get the ...
user avatar
  • 15
0 votes
0 answers
51 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 ...
user avatar
  • 111
0 votes
0 answers
157 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 ...
user avatar
1 vote
0 answers
50 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-...
user avatar
  • 111
0 votes
0 answers
41 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 ...
user avatar
  • 103
0 votes
0 answers
64 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 ...
user avatar
  • 201
0 votes
0 answers
120 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 ...
user avatar
0 votes
1 answer
249 views

Update post if exist from PHP

I want to publish post from php for automation reasons with dynamic data and cronjob. I have almost succeeded, you could say that it works, but in an incorrect way. If the title doesn't exist, create ...
user avatar
0 votes
0 answers
20 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 ...
user avatar
  • 13
0 votes
0 answers
169 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 ...
user avatar
1 vote
0 answers
79 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 (...
user avatar
0 votes
1 answer
499 views

update_post_meta not working with transition_comment_status

I'm trying to save an average of comments as a post meta that needs to be updated every time according to comment status. /** * Gets comment average data. */ function sw_get_averagerev( $post_id ) ...
user avatar
  • 198
0 votes
2 answers
515 views

Custom Meta Box (SELECT2) Not Saving Taxonomy Terms

I have the code, /* * Add a metabox * I hope you're familiar with add_meta_box() function, so, nothing new for you here */ add_action( 'admin_menu', 'rudr_metabox_for_select2_cat' ); function ...
user avatar
1 vote
1 answer
423 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: ...
user avatar
0 votes
0 answers
105 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 ...
user avatar
0 votes
1 answer
500 views

wp_trash_post() duplicates post to trash

I'd like to move a post to the trash in the loop. Here's my code; function run_every_five_minutes() { global $post; $wp_query = new WP_Query(array('cat' => array(1), 'posts_per_page' => ...
user avatar
0 votes
1 answer
521 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, ...
user avatar
0 votes
1 answer
145 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 ...
user avatar
0 votes
1 answer
279 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 ...
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' ) )...
user avatar
  • 17
0 votes
1 answer
803 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 ...
user avatar
0 votes
1 answer
130 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', '...
user avatar
0 votes
1 answer
53 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. ...
user avatar
4 votes
1 answer
2k views

Why wp_update_post() does not update GUID?

Trying to update GUID on a attachment using the wp_update_post() function but its not updating GUID nor its throwing any error. Example code: $post = [ 'ID' => 45, 'guid' => 'https://...
user avatar
  • 181
0 votes
1 answer
2k 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 = $...
user avatar
  • 514
0 votes
2 answers
205 views

How to automatic update date and time when save custom post type

I need to update date and time when I save posts. I see the code on the following thread, but I need to have this trick only for posts contained in my custom post 'new_cpt' Is it possible? ref: ...
user avatar
  • 51
0 votes
1 answer
37 views

How to update the children of a post?

i found nothing about it in the WP reference and Google, so i ask you: I want to update a post by a form - and with it its children. $post = array( 'ID' => $mainid, ...
user avatar
  • 3
0 votes
1 answer
2k views

Post meta data not showing in frontend, until hitting 'update' button

I try to insert around 2000 video-posts into WP. There is a custom field in the theme for the video-url, so I add the video-url to the post meta data with the corresponding field name. ACF seems not ...
user avatar
0 votes
1 answer
2k views

Inline style HTML attribute is being stripped from all elements of a post

I am attempting to publish HTML generated from an external party within Wordpress, but I am getting very inconsistent results with style attribute on all HTML elements, in that if I programmatically ...
user avatar
1 vote
1 answer
1k views

What's the proper way to use a custom table? [closed]

I manually added a table to my wordpress database using sql using CREATE TABLE. I want to add functions for adding, modifying, and removing the data from this table just like with wp_update_user(). ...
user avatar
  • 325
2 votes
1 answer
549 views

Can I edit the wp_post > post_content right before its inserted/updated?

I would need to apply some sort of encryption on whatever gets inserted in the wp_post > post_content, so I was wondering if there is a way, either modifying the core (rather not), or using some ...
user avatar
  • 23
0 votes
1 answer
366 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 ...
user avatar
0 votes
0 answers
33 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 ...
user avatar
  • 113
0 votes
1 answer
39 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 ...
user avatar
1 vote
3 answers
2k views

Clear cache on post of one type when something happens to post of other type

EDIT: Based on @TimHallman's answer I have a follow-up question, please see the bottom of this post. I am trying to do something that is way over my head and the more I think of it, the more ...
user avatar
  • 25
1 vote
0 answers
50 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 ...
user avatar
0 votes
1 answer
6k views

How to change post status from "draft" to "publish"?

My script uses code to set post content. I am also running the WP To Twitter plugin, to auto-tweet those posts. The problem is, whilst the plugin is correctly formulating its tweets using the default ...
user avatar
0 votes
0 answers
434 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', '...
user avatar
0 votes
1 answer
105 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 ...
user avatar
0 votes
1 answer
207 views

wp_update_post ignores if/else

I have a function that publishes a post if it exists as a draft. But the wp_update_post function seems to ignore the if/else and runs before anything else. $post = get_posts(array( ...
user avatar
0 votes
2 answers
1k views

update flamingo_inbound post type after insert

I'm having a difficult time trying to update the flamingo_inbound post author after insert. Basically, I have a hidden field in CTF7 for the company name that is being sent over and correctly stored ...
user avatar
  • 111