WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :)

share|improve this question

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

share|improve this answer

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.

function wpsx_5688_update_post($post_id, $post) {

    // Make sure the post obj is present and complete. If not, bail.
    if(!is_object($post) || !isset($post->post_type)) {

    switch($post->post_type) { // Do different things based on the post type

        case "episode-gallery":
            // Do your episode gallery stuff

        case "another-post-type-slug":
            // Do other stuff

            // Do other stuff


add_action('save_post', 'wpsx_5688_update_post', 1, 2);

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.