在发布上获取自定义post类型元

我正在研究以下代码。为什么发布帖子时无法获得” 自定义帖子” 元信息?我尝试了这个:

function get_cpt_meta($post_ID) { $post = get_post($post_ID); $meta = get_post_custom(); $mfname = $meta['f_name'][0]; $mlname = $meta['l_name'][0]; echo $mfname. " " . $mlname; } add_action('publish_book', 'get_cpt_meta');


function get_cpt_meta($post_ID) { $post = get_post($post_ID); $meta = get_post_custom($post); $mfname = $meta['f_name'][0]; $mlname = $meta['l_name'][0]; echo $mfname. " " . $mlname; } add_action('publish_book', 'get_cpt_meta');

#1【在发布上获取自定义post类型元】请看以下内容:
function get_cpt_meta($post_id){ $f_name = get_post_meta($post_id, 'f_name'); $l_name = get_post_meta($post_id, 'l_name'); echo $mfname. " " . $mlname; } add_action('save_post', 'get_cpt_meta', 11, 1);

    推荐阅读