我经常使用以下方法加载页面上的自定义元框(而不是自定义帖子)。
add_action(\'admin_init\',\'how_we_do_it_meta\');
function how_we_do_it_meta() {
if ( $_SERVER[\'SCRIPT_NAME\'] == \'/wp-admin/post.php\' ) {
$post_id = $_GET[\'post\'] ? $_GET[\'post\'] : $_POST[\'post_ID\'];
$template_file = get_post_meta($post_id,\'_wp_page_template\',TRUE);
if ($template_file == \'page-how-we-do-it.php\') {
add_meta_box(\'how_we_do_it_who-meta\', \'Who we work with...\', \'how_we_do_it_who\', \'page\', \'normal\', \'high\');
add_action(\'save_post\', \'save_how_we_do_it_meta\');
}
}
}