[wp-hackers] Specific hooks for working with custom post types?

Mike Schinkel mikeschinkel at newclarity.net
Sun Mar 28 13:03:35 UTC 2010


On Mar 28, 2010, at 8:39 AM, Simon B wrote:
> I've been learning my way round all the great new support for custom post
> types in WordPress 3.0, but just wondering if there are plans to make
> specific hooks available, for example when saving a custom post type?
> 
> Say I have a custom post type called "case-study", will there be a hook
> "save_case-study" (and "delete_case-study", etc)?
> 
> If not, what's the best way to check the type of the current post?
> 
> At the moment I hook into save_post then check the post type like this:
> 
> if ( 'case-study' == $_POST['post_type'] ) {
>    # save case-study meta...
> }
> 
> but not sure if this is the best method.


In what context are you planning to use this?  Why are you wanting to use $_POST?  

I think what you need would be this:

add_action('wp_insert_post','my_wp_insert_post');

function my_wp_insert_post($post_id,$post) {
	if ( 'case-study' == $post['post_type'] ) {
   		# save case-study meta...
	}
}

Is this not what you need?

-Mike


More information about the wp-hackers mailing list