Skip to content

Instantly share code, notes, and snippets.

@MartinL83
Created July 8, 2013 15:49
Show Gist options
  • Save MartinL83/5950017 to your computer and use it in GitHub Desktop.
Save MartinL83/5950017 to your computer and use it in GitHub Desktop.
Custom Post Type Publish Action Hook. Original code: http://www.wphub.com/custom-post-type-publish-action-hook/
// function to be executed when a custom post type is published
function run_when_post_published()
{
// your function code here
}
// replace {custom_post_type_name} with the name of your post type
add_action('new_to_publish_{custom_post_type_name}', 'run_when_post_published');
add_action('draft_to_publish_{custom_post_type_name}', 'run_when_post_published');
add_action('pending_to_publish_{custom_post_type_name}', 'run_when_post_published');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment