How can I get correct action hook on publish_posts for multiple custom types ?
I have a following problem, I can use this hook for posts or single custom post_type, but I don’t know correct hook for multiple custom post types:
// Post publication for posts
add_filter ( 'publish_post', 'notify_published_post' );
function notify_published_post( $post_id ) {
I would like to publish to all even future custom post_types, so I would like to get something like this:
// Post publication hook for all custom posts
add_filter ( 'publish_anypost', 'notify_published_post' );
function notify_published_post( $post_id ) {
I think you can achieve this by:
1.determine the custom post types by using
get_post_types()
fx2.add action to custom post type when publish
Updated
Create a plugin to show realtime notifications WP-Realtime-Notify
Edit
Paste this code in
functions.php
.It’ll print array of name of custom post types.goto get_post_types and see all parameters.pass correct parameters which gives you required output( change$args
).if you get correct array of name of custom post types for required$args
,change it with my $args in plugin.As i wrote on the doc this plugin has been full tested on WordPress 3.6-beta3 both on localhost and online but i’m not sure how it would work on later RC.
As soon as 3.6 release is coming out i’ll check it out. For testing purpose i would suggest to download beta 3 here: http://wordpress.org/wordpress-3.6-beta3.zip
Remember that to see realtime notification you have to open two browser cause events are obviously not shown to the user that triggered them.
Hope this can help 🙂