Skip to content

Instantly share code, notes, and snippets.

@manchumahara
Created January 30, 2020 05:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manchumahara/35e846858fca18424c2b55e20878ea90 to your computer and use it in GitHub Desktop.
Save manchumahara/35e846858fca18424c2b55e20878ea90 to your computer and use it in GitHub Desktop.
//save_topic_meta_boxes method is hooked from 'save_post'
//this just code sample from my code
/**
* Save topic meta boxes
*
* @param $topic_id
*
* @return mixed
*/
public function save_topic_meta_boxes( $topic_id ) {
//If calling wp_update_post, unhook this function so it doesn't loop infinitely
remove_action( 'save_post', array( $this, 'save_topic_meta_boxes' ) );
/// ...।now write code needed for wp_insert_post or wp_update_post
then again attach the hook again
// re-hook this function
add_action( 'save_post', array( $this, 'save_topic_meta_boxes' ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment