wordpress - add action for unknown custom post type in plugin -


i developing plugin run function when custom post type published. name of custom post types unknown. have tried following code not working.

$args = array( 'public' => true ); $pn_post_types =  get_post_types( $args, 'names' );      foreach ($pn_opt_post_types $pn_opt_post_type){     $pn_action_cpt = 'publish_'.$pn_opt_post_type;     add_action($pn_action_cpt,'pn_notification_publish'); } 

try code , run when post status changes published

function post_published( $new_status, $old_status, $post ) {     if ($new_status == 'publish' ) {         // function perform actions when post status changes publish.     } } add_action( 'transition_post_status', 'post_published', 10, 3 ); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -