Sunday, June 12, 2022
HomeWordPress DevelopmentEntry NEW/UPDATED put up values in save_post() callback perform

Entry NEW/UPDATED put up values in save_post() callback perform


I need to run a “background” perform when a customized put up kind is saved (up to date or created) utilizing the NEW/UPDATED put up values. The “background” perform updates a taxonomy, based mostly on a customized subject within the customized put up kind.

How do I entry the NEW/UPDATED put up values? I am clearly doing one thing dumb right here however I have been at it two hours with no progress.

I believed save_post() was fired after the dbase up to date however I solely get “previous” values.

For the avoidance of doubt, I’m def calling the features appropriately:

perform custom_post_type_callback($post_id) {
  //obvs the background perform is not outlined right here my precise code
  my_background_function($post_id){
     $my_variable = get_post($post_id); // <- that is all the time the "previous" values
  };
}

add_action( 'save_post_custom_post_type', 'custom_post_type_callback' );

It really works completely if I save the put up AGAIN.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments