作为wordpress的新手,我在我的“slider”自定义帖子类型中添加自定义元框时遇到了问题,我在一些旧的wp主题中使用了这种类型。
我收到一个警告:
Warning: call_user_func() expects parameter 1 to be a valid callback, function \'new_meta_box\' not found or invalid function name in...
这是我的代码:
/////////////////////////////////////
/* Custom post type slider */
///////////////////////////////////
add_action( \'init\', \'create_post_type_slider\' );
function create_post_type_slider() {
register_post_type( \'slider\',
array(
\'labels\' => array(
\'name\' => __( \'Sliders\' ),
\'singular_name\' => __( \'slider\' ),
\'search_items\' => __( \'Search sliders\' ),
\'all_items\' => __( \'All sliders\' ),
\'edit_item\' => __( \'Edit slider\' ),
\'update_item\' => __( \'Update\' ),
\'add_new\' => __( \'Add new slider\' ),
\'add_new_item\' => __( \'Add new slider\' ),
\'view_item\' => __( \'View slider\' ),
\'new_item_name\' => __( \'New slider Name\' )
),
\'public\' => true,
\'supports\' => array(\'title\',\'taxonomies\'),
\'has_archive\' => false,
)
);
flush_rewrite_rules( false );
}
/* custom post type category */
add_action( \'init\', \'create_taxonomie_sliderpos\' );
function create_taxonomie_sliderpos() {
$labels = array(
\'name\' => __( \'Slider Position\' ),
\'singular_name\' => __( \'Slider Position\' ),
\'search_items\' => __( \'Search slider Positions\' ),
\'all_items\' => __( \'All Slider Position\' ),
\'parent_item\' => __( \'Parent Slider Position\' ),
\'parent_item_colon\' => __( \'Parent Category:\' ),
\'edit_item\' => __( \'Edit Slider Position\' ),
\'update_item\' => __( \'Update slider Position\' ),
\'add_new_item\' => __( \'Add\' ),
\'new_item_name\' => __( \'New slider Position Name\' ),
);
register_taxonomy(\'sliderpos\',\'slider\',array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
));
flush_rewrite_rules( false );
}
//
$prefix = "_ct_";
$slide_info = array (
"imglnk" => array(
"type" => "uploadfield",
"name" => "upload_image",
"std" => "",
"width" => "60%",
"title" => __(\'Slide image:\'),
"description" => __(\'Enter the link of the slide image or upload your own image. <strong> Image must be at least 348px height.</strong>\')),
"captitle" => array(
"type" => "textfield",
"name" => $prefix."caption_title",
"std" => "",
"width" => "60%",
"title" => __(\'Caption Title\'),
"description" => __(\'Enter caption title\')),
"captext" => array(
"type" => "textarea",
"name" => $prefix."caption_text",
"std" => "",
"title" => __(\'Caption Text\'),
"description" => __(\'Enter caption text\')),
"capalign" => array(
"type" => "align",
"name" => $prefix."align",
"std" => "",
"title" => __(\'Slide Alignment\'),
"description" => __(\'\')),
"caplink" => array(
"type" => "textfield",
"name" => $prefix."slide_link",
"std" => "",
"width" => "60%",
"title" => __(\'Slide Link\'),
"description" => __(\'Enter slide link with http://\')),
);
//Create Metabox on page
function create_meta_box_slider() {
global $slide_info;
add_meta_box( \'new-meta-boxes-slider\', __(\'slider Settings\'), \'new_meta_box\', \'slider\', \'normal\', \'high\', array(\'inputs\'=>$slide_info) );
}
add_action(\'admin_menu\', \'create_meta_box_slider\');
//Add $slide_info var to $meta_box_groups array
global $meta_box_groups;
$meta_box_groups[] = $slide_info;
有什么帮助吗?
谢谢