What hook gets called when I edit or publish a custom post type of name ‘episode gallery’ ?
I tried following but none worked.
add_action('save_post', 'update_custom_ngg_table');
add_action('update_postmeta', 'update_custom_ngg_table');
add_action('publish_post', 'update_custom_ngg_table');
add_action('edit_post', 'update_custom_ngg_table');
add_action('edit_page', 'update_custom_ngg_table');
add_action('publish_page', 'update_custom_ngg_table');
add_action('save_page', 'update_custom_ngg_table');
add_action('publish_episode-gallery', 'update_custom_ngg_table');
I am about to give up 🙂
Unless I misunderstand your question, you want {$new_status}_{my-custom-post-type}
Take a look at the hook registration.
This page (from Pippin’s Posts)* does a better job than I could at explaining it, but from your example, you would want
add_action('publish_episode-gallery', 'update_custom_ngg_table');
According to the source, the following status are available:
publish, future, draft, pending, private, trash, auto-draft and inherit.
* Mirror at the Web Archive
It’s always save_post, no matter what the post type. save_post also runs when creating and publishing a new post.
From inside your hooked function you can figure out what kind of post is being handled–it gets passed both the post id and the entire post object.
Another thing to consider is that–depending on your exact problem, I’m not sure what you’re trying to do–it might not be that the hook isn’t firing, but that the code inside your hooked function has errors. Just something else to check if you’re stuck.
If you want to perform an action when any custom post Edit/insert-
If you want to make a change to a specific post type, you can also use the
save_post_$this->post_type
hook documented here.