是的,你离它很近。只需使用$postarr
此过滤器的参数:
add_filter( \'wp_insert_post_data\' , \'wpse128138_wp_insert_post_data\', 99, 2 );
function wpse128138_wp_insert_post_data( $data, $postarr ) {
// run this only for posts
if ( \'post\' != $postarr[\'post_type\'] )
return $data;
foreach( $postarr[\'post_category\'] as $category_id ) {
if ( is_wp_error( $category = get_category( $category_id ) ) )
continue; // invalid category, just pass
// and here you can safely use the $category object
}
return $data;
}