[wp-hackers] How to dynamically register hook with post type ?
Tommy Leunen
tom at tommyleunen.com
Sun Jan 15 15:21:29 UTC 2012
Hi,
I would like to dynamically register some hook with the post types, and
custom post type I get from get_post_types().
I first try to do this :
$types = get_post_types();
foreach($types as $type => $whatever)
{
add_action('publish_'.$type, 'my_publish_post', 99);
}
That code works great for individual installation of WordPress. But when I
try it with Network sites. The array is empty so don't add the actions.
I don't really know how to resolve that. Have you an idea ? I'm guessing
some of you already use something like that to register the hook with
custom post type ?
Thanks.
-Tommy
More information about the wp-hackers
mailing list