Is there a save_post hook for custom post types?

Example: save_my_post_type

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

3 Answers 3


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

function save_post_callback($post_id){
    global $post; 
    if ($post->post_type != 'MY_CUSTOM_POST_TYPE_NAME'){
    //if you get here then it's your post type so do your thing....

New solution, as of WP 3.7: save_post_{$post_type}

add_action( 'save_post_my_post_type', 'wpse63478_save' );
function wpse63478_save() {
    //save stuff

See the note on the codex page


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');
  • can you expand this to provide more context? What is course_metabox_save_value and what did you mean by special metabox? The answers a bit concise/terse
    – Tom J Nowell
    Nov 6 at 15:01
  • [course]_metabox_save_value, course is a post type, If you write the name of the post type, the function will be called only when an post of the same post type is being saved Nov 17 at 7:07
  • ex: add_action('save_post_product', 'course_metabox_save_value'), call function course_metabox_save_value(); whene product post type in woocommerce save or publish Nov 17 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.