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
0 answers
14 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 ...
user avatar
  • 103
2 votes
0 answers
12 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 ...
user avatar
0 votes
1 answer
31 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?
user avatar
1 vote
1 answer
31 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 ) ) { ...
user avatar
  • 155
0 votes
1 answer
18 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() )?
user avatar
0 votes
0 answers
16 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 ...
user avatar
  • 1
0 votes
0 answers
31 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
0 answers
23 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 ...
user avatar
1 vote
0 answers
24 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 ...
user avatar
  • 452
1 vote
1 answer
14 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 ...
user avatar
1 vote
0 answers
17 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 ...
user avatar
  • 11
1 vote
0 answers
56 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 ...
user avatar
0 votes
1 answer
26 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 '...
user avatar
  • 1,870
0 votes
0 answers
27 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"/> <...
user avatar
0 votes
0 answers
9 views

Select input in metabox not updated

I try to figure it out why my select input did not update the value. I have placed the select input in the header of a metabox, the same what Woocommerce did with the producttype selector. ...
user avatar
0 votes
1 answer
25 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 ...
user avatar
  • 13
0 votes
1 answer
45 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 ...
user avatar
  • 446
0 votes
1 answer
55 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 ...
user avatar
0 votes
0 answers
23 views

Bookmarking custom template pages which all have the same page ID

I have a custom page I created in WP which displays different real estate listings. Since it is a custom page the page ID is always the same. For example both of these URLs display different ...
user avatar
3 votes
2 answers
272 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 ...
user avatar
  • 135
0 votes
1 answer
30 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 ...
user avatar
  • 39
1 vote
0 answers
127 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 ...
user avatar
0 votes
1 answer
97 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 ...
user avatar
  • 123
0 votes
0 answers
42 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 ...
user avatar
0 votes
0 answers
149 views

Save a custom field in a custom table when saving a draft

I created a custom metabox with a custom field inside. I attach code. add_action( 'admin_menu', 'mtb_add_metabox' ); function mtb_add_metabox() { add_meta_box( 'mtb_metabox', '...
user avatar
  • 43
3 votes
0 answers
797 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 ...
user avatar
0 votes
1 answer
141 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 ...
user avatar
  • 618
0 votes
0 answers
57 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( $...
user avatar
1 vote
0 answers
82 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 ...
user avatar
  • 11
0 votes
2 answers
320 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,...
user avatar
  • 103
0 votes
0 answers
133 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....
user avatar
0 votes
2 answers
34 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 ...
user avatar
0 votes
0 answers
109 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 ...
user avatar
0 votes
1 answer
44 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 ...
user avatar
0 votes
1 answer
262 views

Change post author without using wp_update_post()

The standard or more obvious way to change a post author in WP is to use the wp_update_post() function, as shown in this question. But I am having an issue, described as follows: // Inside the ...
user avatar
1 vote
0 answers
51 views

Use the backbone.js client to save custom post type meta

So I have this small piece of code that renders an array of IDs: const selected = this.$data.list.selected; function get_ids(input, field) { const output = []; for (let i=0; i < input....
user avatar
  • 11
0 votes
1 answer
320 views

Save values from a pre_post_update

I have looked around for an answer here but I didn't find exactly what I'm looking for so I give this a try: I'm creating a plugin. I've created a custom post type I've created a metabox associated ...
user avatar
1 vote
0 answers
16 views

How can I create a new user account while creating a new post, and then set that new user as the author of that new post?

I have a custom meta box with some user information fields, and when the post is published, the new user account is created, along with the new post. However, the new post's author is set as the ...
user avatar
  • 11
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
1 answer
151 views

Use value from ACF to populate other fields

I am struggling with this problem. I have a group pf ACF fields and a XML file with the corresponding values. What I want is the user to be able to fill one field (with an id) and on the Publish post, ...
user avatar
0 votes
2 answers
67 views

Remove a category from a post when saving a new post

I'm having problems with my code. I'm trying to remove a category from a post that's using that category and then adding that same category when saving a post. For example, if I have a post that's ...
user avatar
0 votes
1 answer
329 views

Save post action is called twice

I've seen this posted several times with no perfect answer: I have an action hook for save_post on a CPT. I've tried everything I could find but it always gets called twice: Here's my code: function ...
user avatar
0 votes
1 answer
111 views

woocommerce_product_quick_edit_save hook not fired

I´m trying to add custom fields in the quick edit of woocommerce product. I managed to show fields and populate with jquery but I don´t manage to save data updated. add_action( 'quick_edit_custom_box',...
user avatar
  • 770
0 votes
0 answers
82 views

Custom taxonomy only gets saved in quick edit

I have set up 2 custom taxonomies for my posts: verdicts and sponsors. The problem is that sponsors do not get saved when publishing a post, it can only get saved when I check it in quick edit mode. ...
user avatar
1 vote
0 answers
91 views

wp_schedule_single_event issue with save_post hook in gutenberg

I am using the "save_post" hook to call wp_schedule_single_event. Everything works as expected with the classic editor, however when I try a post in gutenberg there isn't actually a cron ...
user avatar
  • 111
0 votes
1 answer
42 views

Changing new post to "pending" on publish - but "Publish failed" - why?

I only want 2 admis to be able to publish events. So I want to change any new event published by any other user to be set to "pending" when the post is "published." Which, I guess, ...
user avatar
0 votes
3 answers
697 views

Execute php after post save/update

I have created a php script (generate.php) which is querying posts on set criteria and then writing result in custom xml file. I would like to execute the generate.php everytime the post Save/Update ...
user avatar
  • 173
0 votes
1 answer
60 views

Saving multiple fields (dropdown and text) in custom metabox

I have seen this question asked a bunch but nothing seems to work. I have a simple metabox within a CPT that needs to save two values. It needs to save a dropdown of pages and a url text field. I can ...
user avatar
0 votes
1 answer
76 views

Copy permalink to clipboard automatically when publish/update posts?

When a post gets published/updated, a message will be displayed which gives the permalink. Yes we can copy the permalink to clipboard manually, but I want it to be copied automatically, just like it ...
user avatar
  • 1
1 vote
0 answers
15 views

Keep a post copy when this one is updated - issue

I try to keep a copy of the previous version a custom post when this one is updated. It works, but duplicate the previous version twice. Help appreciated ! DUPLICATE FUNCTION : function duplicate($...
user avatar
  • 11

1
2 3 4 5
8