首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在标题后添加metabox

在标题后添加metabox
EN

Stack Overflow用户
提问于 2014-11-08 19:07:40
回答 3查看 3K关注 0票数 1

我已经在wordpress管理部分添加了metabox。我的代码:

代码语言:javascript
复制
   add_meta_box('cabcd', __( 'Page Settings', 'bg_textdomain' ), 'myplugin_meta_box_callback', 'page', 'side' );

现在我希望它显示在标题部分之后。我该怎么做呢?

EN

回答 3

Stack Overflow用户

发布于 2014-11-08 19:16:08

您必须设置add_meta_box()$priority

代码语言:javascript
复制
add_meta_box(
   'cabcd', 
   __( 'Page Settings', 
   'bg_textdomain' ), 
   'myplugin_meta_box_callback', 
   'page', 
   'side', 
   'high' // priority
);
票数 2
EN

Stack Overflow用户

发布于 2014-11-08 19:16:15

此代码用于添加meta box

代码语言:javascript
复制
  <?php
         add_meta_box( $id, $title, $callback, $post_type, $context,
                $priority, $callback_args );
      ?>

$priority

(字符串)(可选)框应显示的上下文中的优先级('high‘、'core’、'default‘或'low')默认值:'default’

您可以试用此 (set the priority to high)

代码语言:javascript
复制
 add_meta_box('cabcd', __( 'Page Settings', 'bg_textdomain' ), 'myplugin_meta_box_callback', 'page', 'side','high' );

更多信息click

票数 1
EN

Stack Overflow用户

发布于 2016-09-07 13:15:30

代码语言:javascript
复制
<?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' );
?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26816436

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档