Questions tagged [wp-update-post]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
74 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
  • 255
5 votes
1 answer
131 views

Bulk post approval and publishing doesn't work

I'm new to WordPress plugin development. I'm trying to develop a simple plugin that creates a sub-menu named Approval under Posts menu and checks if any draft post has the post meta approve set to ...
Karma's user avatar
  • 176
0 votes
0 answers
43 views

How to Auto Update Wordpress Post after specific time?

I hope you all are doing well. I need some help to update my post automatically after 1 year. I read alot of articles and hope this can be achive using wp-cron-jobs. Problem Explanation: Here are my ...
Developer Mohsin's user avatar
0 votes
1 answer
105 views

How can I use wp_after_insert_post with $current_screen?

I'd like to call add_action( 'wp_after_insert_post' on particular screens. I'm currently checking the page like so followed by calling the wp_after_insert_post hook. It doesn't seem to fire but does ...
Motivated's user avatar
  • 181
1 vote
1 answer
576 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
0 votes
1 answer
56 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
101 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
1 answer
409 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($...
kolja's user avatar
  • 103
0 votes
0 answers
200 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
501 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
100 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
2 answers
1k 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 ...
TARKUS's user avatar
  • 137
0 votes
1 answer
69 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 ...
Jani's user avatar
  • 15
0 votes
1 answer
181 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
266 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
1 vote
0 answers
130 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
0 votes
0 answers
88 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
108 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
  • 205
0 votes
0 answers
223 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
1 answer
741 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 ...
JonatanPN's 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 ...
AHrtzt's user avatar
  • 13
0 votes
1 answer
230 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
1 vote
0 answers
98 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
0 votes
1 answer
592 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 ) ...
Bikram's user avatar
  • 328
0 votes
2 answers
674 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 ...
Mohammad Mehedi Hassan's user avatar
1 vote
1 answer
500 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
0 votes
0 answers
149 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
649 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' => ...
Kevin S's user avatar
0 votes
1 answer
690 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
192 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
397 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
1 answer
1k 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
155 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
68 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
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://...
Harry's user avatar
  • 301
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 = $...
samjco's user avatar
  • 559
0 votes
2 answers
330 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: ...
Giulio's user avatar
  • 51
0 votes
1 answer
46 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, ...
Plato's 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 ...
rhyno183's user avatar
0 votes
1 answer
3k 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 ...
Mattisdada's 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(). ...
ellen's user avatar
  • 335
2 votes
1 answer
663 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 ...
Pavel's user avatar
  • 23
0 votes
1 answer
413 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 ...
Jillian Hoenig's user avatar
0 votes
0 answers
35 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
51 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 ...
Ragnaboy's user avatar
1 vote
3 answers
3k 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 ...
erolha's user avatar
  • 25
1 vote
0 answers
52 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
0 votes
1 answer
7k 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 ...
Robert Andrews's user avatar
0 votes
0 answers
459 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