我有一些问题,包括我的自定义元框文件。我有这样一个结构:
发布元数据。php
cmb公司
加载Triser\\u meta\\u框。php启动。php显示。php保存。php在我的博文meta中。php我有以下内容:
// Load Meta Boxes
function add_custom_meta_box()
{
require_once dirname( __FILE__ ) . \'/cmb/teaser_meta_box/load.php\';
}
add_action(\'add_meta_boxes\', \'add_custom_meta_box\');
// Initiate Meta Box Fields
require_once dirname( __FILE__ ) . \'/cmb/epteaser_meta_box/initiate.php\';
// Display Meta Box Fields
require_once dirname( __FILE__ ) . \'/cmb/epteaser_meta_box/display.php\';
// Save Meta Box Fields
function save_custom_meta($post_id)
{
global $meta_fields_epteaser, $post; // Need to put name of each meta field here
// verify nonce
if (!wp_verify_nonce($_POST[\'custom_meta_box_nonce\'], basename(__FILE__)))
return $post_id;
// check autosave
if (defined(\'DOING_AUTOSAVE\') && DOING_AUTOSAVE)
return $post_id;
// check permissions
if (\'page\' == $_POST[\'post_type\']) {
if (!current_user_can(\'edit_page\', $post_id))
return $post_id;
} elseif (!current_user_can(\'edit_post\', $post_id)) {
return $post_id;
}
require_once dirname( __FILE__ ) . \'/cmb/epteaser_meta_box/save.php\';
}
add_action(\'save_post\', \'save_custom_meta\');
当我尝试这样做时,元框不会按其应该的方式工作,但是我没有收到任何错误,比如include是错误的等。如果我尝试将代码直接放入文件中以启动和显示元框,那么它就会工作。关于为什么这两个包含项在包含时似乎不起作用,有什么想法吗?
谢斯罗伯特