我已经在wordpress管理部分添加了metabox。我的代码:
add_meta_box('cabcd', __( 'Page Settings', 'bg_textdomain' ), 'myplugin_meta_box_callback', 'page', 'side' );现在我希望它显示在标题部分之后。我该怎么做呢?
发布于 2014-11-08 19:16:08
您必须设置add_meta_box()的$priority
add_meta_box(
'cabcd',
__( 'Page Settings',
'bg_textdomain' ),
'myplugin_meta_box_callback',
'page',
'side',
'high' // priority
);发布于 2014-11-08 19:16:15
此代码用于添加meta box
<?php
add_meta_box( $id, $title, $callback, $post_type, $context,
$priority, $callback_args );
?>$priority
(字符串)(可选)框应显示的上下文中的优先级('high‘、'core’、'default‘或'low')默认值:'default’
您可以试用此 (set the priority to high)
add_meta_box('cabcd', __( 'Page Settings', 'bg_textdomain' ), 'myplugin_meta_box_callback', 'page', 'side','high' );更多信息click
发布于 2016-09-07 13:15:30
<?php
function custom_meta_box_markup()
{
}
function add_custom_meta_box()
{
add_meta_box("demo-meta-box", "Custom Meta Box", "custom_meta_box_markup", "post", "after_title", "high", null);
}
add_action("add_meta_boxes", "add_custom_meta_box");
function edit_form_after_title() {
// get globals vars
global $post, $wp_meta_boxes;
do_meta_boxes( get_current_screen(), 'after_title', $post );
// unset 'ai_after_title' context from the post's meta boxes
unset( $wp_meta_boxes['post']['after_title'] );
}
add_action( 'edit_form_after_title', 'edit_form_after_title' );
?>https://stackoverflow.com/questions/26816436
复制相似问题