Is there a save_post hook for custom post types?

Is there a save_post hook for custom post types?

Example: save_my_post_type

Read More

I know there is publish_my_post_type but I’m looking for a save hook.

Related posts

Leave a Reply

3 comments

  1. the hook is the same save_post just make sure its your post type ex:

    add_action('save_post','save_post_callback');
    function save_post_callback($post_id){
        global $post; 
        if ($post->post_type != 'MY_CUSTOM_POST_TYPE_NAME'){
            return;
        }
        //if you get here then it's your post type so do your thing....
    }
    
  2. call function my_func() whene publish(save) special post type

    add_action('save_post_[name_of_post_type]', ' my_func');
    

    call function my_func() whene publish(save) all post type (post, page, product, …)

    add_action('save_post', 'my_func');