我相信您可以使用save\\u post挂钩来完成这项工作,而不是对帖子的post类型及其post meta的值进行条件检查。
add_action( \'save_post\', \'do_some_function\');
function do_some_function($post_id) {
global $post;
$post_type_as_taxonomy = array(\'cpt-1\',\'cpt-2\'); // this is your hooked custom post types
$post = get_post( $post_id );
if(in_array($post->post_type, $post_type_as_taxonomy) && $post->post_status==\'publish\'){ // check if the post is hooked & published
$my_meta = get_post_meta($post_id, \'my-meta\', true); // check if it has a post meta with the ket \'my-meta\'
if($my_meta){
// do your hook function here
}
}
}