Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // called when saving a post.
- public function tl_save_post($post_id){
- // dont do this on auosave.
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
- return;
- // verify this came from the our screen and with proper authorization,
- // because save_post can be triggered at other times
- $post = get_post($post_id);
- if (!isset($post->post_type) || 'my_post_type' != $post->post_type ) {
- return;
- }
- // unhook this function so it doesn't loop infinitely
- remove_action( 'save_post', 'tl_save_post, 100 );
- // do stuff that might trigger another Save
- /* stuff here */
- // put back the hook
- add_action( 'save_post', 'tl_save_post, 100 );
- }
- add_action( 'save_post', 'tl_save_post, 100 );
Add Comment
Please, Sign In to add comment