Questions tagged [save-post]

save_post is an action triggered whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. The data for the post is stored in $_POST, $_GET or the global $post_data, depending on how the post was edited.

Filter by
Sorted by
Tagged with
0 votes
1 answer
99 views

How to automatically update ACF field value every year?

I'm using ACF in my custom post type and I have 2 numeric fields: one for Birth year and another for Age. I want to update the age field automatically based on the birth year field value. I found out ...
Adriana Leites's user avatar
1 vote
1 answer
95 views

ERR_CONNECTION_RESET on post save or add media

About a year ago the site was moved to another host (same domain name). Every time I attempt to save a post, page or upload media, I'm immediately sent a connection reset error (This webpage is not ...
Alex Gubin's user avatar
1 vote
0 answers
20 views

Resaving posts to update static blocks

I changed markup in my custom static block and now I have to resave custom posts where I use them in order to update what is shown in the front. I tried to automatise procedure by using wp cli command ...
Lovor's user avatar
  • 861
0 votes
1 answer
37 views

How do I set a custom post type Category after import using wp_set_post_terms

I'm importing Events from a Salesforce Event Manager into WordPress, specifically into the The Events Calendar. The Events Calendar creates a CPT called Events. It also has its own Categories, which ...
Mikey B's user avatar
0 votes
0 answers
17 views

A way to see real changes of posts inside an action?

We want to create a service that copies an article from the WP-API every time it has been changed. Therefore we want to write a message into a queue. We need to just to know tree states: Post was new ...
ssilk's user avatar
  • 1
0 votes
0 answers
16 views

Multiple triggers when publishing, saving or updating a post in WordPress

I have set up a webhook to be triggered when a post is published, saved, or updated on my WordPress website. The webhook includes the post ID, permalink, and a custom field with ID 'syncal' as JSON. ...
Robin Alexander's user avatar
0 votes
1 answer
130 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
0 votes
0 answers
56 views

Detect, if post is saved manually or programmatically in save_post-hook

I have a set of 1k posts which are regularly updated through an automated import. Each post is hashed so I can quickly detect, if I need to update a specific post or not, compared to the import file. (...
nyan's user avatar
  • 68
0 votes
1 answer
199 views

Save_Post change Custom Post Type Post title to post id number

I have a Custom Post Type with the slug of "sightings". I do not need a post title, so I have removed the functionality - but now the posts are being saved as (no-title). I read about the ...
Nebin Esquire's user avatar
1 vote
1 answer
96 views

Get category of post inside save_post hook

I don't have much experience with hooks in WordPress so i have found a problem who don't look too difficult, but i can't find the answer. In my project i have a metabox who will get the content after ...
Matheus Ribeiro's user avatar
0 votes
0 answers
19 views

How to use wp_set_object_terms depending on page ID?

The function to set custom term works fine. add_action( 'save_post', 'set_custom_term', 30, 2 ); function set_custom_term( $post_id, $post ) { wp_set_object_terms($post_id, 'guitar', 'instrument',...
Kim Caspe's user avatar
0 votes
1 answer
23 views

UI does not show correct Slug after modified using save_post action

When a WP user creates a new Post the default behavior is that the Title is used as the basis for the Slug which forms a major part of the URL/Permalink. I am changing this default behavior. My code (...
donohoe's user avatar
  • 153
0 votes
0 answers
79 views

acf/save_post affecting WP_Query results

I have CPT Events, which lists from WP_Query and orders by meta query where events that have date/time less then current are not shown + ordered by most closest events to further. Array ( [...
bruno's user avatar
  • 1
0 votes
0 answers
24 views

if condition from post_meta not working in save_post

I'm new to Wordpress, and I am trying to make a condition to run something in save_post if a checkbox is enabled. Right now my code is like this: add_action( 'save_post', 'ac_verifica_links' ); ...
Juliano de Miranda's user avatar
0 votes
1 answer
78 views

Wp doesn't save meta box data

My WP doesn't save my meta box data. I see the metabox and the field, but the data doesn't saving. Somebody could help me? Thank you. This is the code: // 1. Metabox létrehozása function my_meta_box(){...
Eszter's user avatar
  • 1
0 votes
0 answers
24 views

Sanitize and Save metabox values

I am learning WordPress Plugin development. How to Sanitize and Save metabox values in WordPress Plugin ? I am using below code. //Filtering $fields = [ 'location_input' => ...
Foysal's user avatar
  • 417
0 votes
1 answer
142 views

get_the_terms inside save_post gives old terms

When I use get_the_terms inside save_post, I get the old taxonomy terms. This is something that I would expect from pre_post_update, but why does it happens to save_post ? And, more important, how to ...
Tahi Reu's user avatar
  • 206
0 votes
2 answers
138 views

Save frontend submission form field as custom field

I use plugin for submitting posts from frontend. It's a field builder. Maybe it uses wp_insert_post() function, I really don't know. Here I use my custom shortcode, please check here for the code: ...
Juraj's user avatar
  • 11
1 vote
1 answer
66 views

Can this react script be optimized? How to make it faster

Rephrased the question on August 9th. This is my first attempt to work with Wordpress blocks and also my first time working with React. The code below adds the possibility to conditionally show blocks....
Tsjippy's user avatar
  • 11
0 votes
1 answer
238 views

Add action save post when create and publish

I try to use the hook save_post in my wp but I have a problem. I do this : function when_save_post_match($post_id, $post){ if (isset($post->post_status) && 'auto-draft' == $post->...
Gpi's user avatar
  • 101
0 votes
0 answers
46 views

Access NEW/UPDATED post values in save_post() callback function

I want to run a "background" function when a custom post type is saved (updated or created) using the NEW/UPDATED post values. The "background" function updates a taxonomy, based ...
dtw's user avatar
  • 105
2 votes
0 answers
53 views

Get $_POST & $_REQUEST values before adding/updating post

I've done this many times before, but it stopped working and I can't figure out why and haven't found a way to re-accomplish the same task. GOAL: intercept submitted values from $_POST/$_REQUEST ...
patrick34's user avatar
0 votes
1 answer
36 views

Update current WP post every 3 minutes [closed]

I wish to auto update/publish the changes of a post I am editing every 3 minutes. Any idea how can I achieve that?
Ryan Tan's user avatar
1 vote
1 answer
54 views

save_post_{CPT} not updating the 'sticky_posts' option

add_action( "save_post_{CPT}", 'update_sticky', 15, 1 ); function update_sticky( $post_id ) { $stickies = get_option( 'sticky_posts' ); if ( ! in_array( $post_id, $stickies ) ) { ...
Tahi Reu's user avatar
  • 206
0 votes
1 answer
93 views

How to check post meta isset or not empty during publish/save post?

How to check if a specific post meta isset/!emtpy during updating or publishing a post ( save_post() )?
Amenadiel's user avatar
0 votes
0 answers
59 views

save_post trigerred twice

I am trying to add more functionality to the update button. My end result is that I wish to call a python script but for now I am messing around with writing a log file. This is resulting in the log ...
Martha's user avatar
  • 1
0 votes
0 answers
60 views

Updating failed. The response is not a valid JSON response. specific to my browser when I include javascript in my html

I was able to insert custom html into my gutenberg wordpress editor (hosted by bluehost) and test my code by preview with no problems. I made calls to google maps and fetch() to get a list of ...
Sugarplumclaus's user avatar
1 vote
0 answers
70 views

How can I remove the kses filters when saving a specific post type ? (it breaks my JSON)

I want to store JSON in my post_content, but the kses filters makes it break. I would like to remove the kses filters when creating or updating (well, saving) a specific post type; anywhere in the ...
gordie's user avatar
  • 482
1 vote
1 answer
43 views

Pre insert data when adding new custom post fire a json error

here is what i have tried function mec_locations_cpt_add_content ( $data, $postarr) { //, $postarr if ( 'mec_locations_cpt' !== $postarr['post_type'] ) { return $data; } if ...
ari elbaz's user avatar
1 vote
0 answers
24 views

Plugin with action 'save_post' needs to press publish twice on order to publish

I have an old plugin, which used to work fine (years ago). Now I have to press publish twice to publich the post. The problem is in the blocks below. The used variables are declared above the code ...
lassec's user avatar
  • 11
1 vote
0 answers
233 views

Strange issue saving custom field data for a WooCommerce order

I have an issue with WordPress update_post_meta() function. So I have made a custom input field for WooCommerce orders which hold Tracking number. Most of the time everything is running smooth and I ...
John McClane's user avatar
0 votes
1 answer
38 views

Custom Post Meta from custom metaboxes is randomly being deleted

For a while now I've been applying and updating some custom metaboxes that my company re-uses on different sites. (Not the same metaboxes, but the same methodology.) Essentially it allows for the '...
Tony Djukic's user avatar
  • 1,964
0 votes
0 answers
190 views

Save / Update meta data as multidimensional array

I need some help with saving my meta data from a post. On the editpage I have the following input fields <input type="text" name="data[color][]" value="red"/> <...
Liekeee's user avatar
0 votes
1 answer
131 views

Adding term to a custom taxonomy based on term from product category

spent over four hours on this and still hitting a wall, hope StackExchange knows better. :/ Basically, I have some Woo products and whenever a new product is added, its name should be saved as a term ...
Tatex's user avatar
  • 23
0 votes
1 answer
86 views

Exclude URL's from sanitize_html_classes

I've searched through the similar questions but found nothing. I've coded a meta box for adding custom URL's which get added to buttons on single posts but when the URL is added to the meta box field ...
Brad Dalton's user avatar
  • 6,886
0 votes
1 answer
164 views

How check if a post is saved from backend or frontend?

I created a custom post type called wasb_contact which can be inserted and edited both from the backend and from the frontend (through a form I created). The CPT has some custom meta fields which are ...
icolumbro's user avatar
3 votes
2 answers
2k views

Get updated post meta on save_post action?

I'm trying to save post id and keyword (Yoast Focus Keyword) to a custom table when post is created or updated via save_post action. It saves everything fine on Publish (first-time) but when I update ...
Key's user avatar
  • 135
0 votes
1 answer
132 views

Custom meta box values are not getting saved for my custom post type

I have created one dummy post type to check the values, if it's getting saved or not. However it's saving values for 'text input and text area' but remaining values (checkbox, select, images) are not ...
Ricky's user avatar
  • 53
1 vote
0 answers
325 views

"The link you followed has expired" & "Error while saving" messages when adding new post

I'm currently unable to publish new posts on my wordpress site. Whenever I try, I get a "The link you followed has expired" error after clicking the "publish" button. Also, as I'm ...
Harrison's user avatar
0 votes
1 answer
204 views

Wordpress sent multiple requests on update

I have a problem with hooks being fired multiple times when I press update on a post (page in this example) I tried everything here: Unable to prevent function using save_post firing twice But since ...
Borje's user avatar
  • 123
0 votes
0 answers
43 views

How to create a user ability to save pages with full url?

Problem: I have a real estate website with dynamic pages. For example when you click on a property it links to http://example.com/property/?id=23432434. I want to give users the ability to save a ...
Joey Lawrence's user avatar
3 votes
0 answers
2k views

Correct processing of `$_POST`, following WordPress Coding Standards

Background I'm building a project that according to the specifications need to follow the WordPress Coding Standards. I am using phpcs to scan my code. If I try to pass $_POST-data into a function ...
Fabian Mossberg's user avatar
0 votes
1 answer
262 views

Run function after a post has finished saving - callback function perhaps?

Upon saving a new post (of a certain post type), a given operation has to run. The problem is that the operation is calling an external (slow) API, which means that the (not logget in) end-user might ...
Zeth's user avatar
  • 828
0 votes
0 answers
165 views

Add Tag to post after publishing

I want to add a specific tag to posts being published, I tried the following code and searched for answers here but it doesn't work. Does anyone have an idea why? function tag_to_published_post( $...
fourorty's user avatar
1 vote
0 answers
181 views

Custom Taxonomy terms aren't getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?

I am using Woocommerce, Elementor, ACF Custom Fields and CPT for Custom Post types. I have a custom taxonomy called 'biographies' which has some associated custom fields (first name, last name, birth ...
Tim L's user avatar
  • 11
0 votes
2 answers
722 views

Wordpress publish_post hook not getting featured image and meta on first publish, but works on updating title

I've been struggling to find a solution for this and I don't know if it's the Gutenberg editor or if it's the hook publish_post. Hook: function api_method($post_id) { // If this is just a revision,...
msbodetti's user avatar
  • 103
0 votes
0 answers
457 views

Is there a way to get rendered html content of a WP post after updating?

I tried adding a filter at the content etc but that one just gives access to content stored in wp_posts. I am interested in getting the rendered html with meta tags etc for a post, after it is updated....
chatnoir's user avatar
0 votes
2 answers
36 views

When the new post which has no image published, save the specific image as the featured image ( by category )

As the title, I would like to save the post with the specific image as the featured image, when it is new published. Also I would like to save different images which is filtered by categories. I have ...
shinny0129's user avatar
0 votes
0 answers
144 views

Post and Pages section inside WordPress admin are completely blank

Meta Tags - Undefined array due to meta tags! I have created my own custom post meta tags but all works fine until I test my WordPress theme on the new WordPress Installation. What I came through ...
Owaiz Yusufi's user avatar
0 votes
1 answer
271 views

How to detect that the save_post hook is calling the callback associated to the current edit post page only

I am using the save_post hook to handle updates in a post that are done via the admin edit post page. But since I have more than ten custom post types, the save_post associated to each one of them is ...
Álvaro Franz's user avatar

1
2 3 4 5
8