最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugin development - add_meta_box does not display meta box in Admin

programmeradmin0浏览0评论

I have two wordpress sites:

  1. running on localhost server (PHP7.3)
  2. hosted on Bluehost (PHP7.2)

The metabox gets added on my local website, but the same piece of code does not work on bluehosted website.

What is wrong?

add_action( 'add_meta_boxes', 'add_mu_address_meta_box' );

function add_mu_address_meta_box() {
    add_meta_box(
        'your_fields_meta_box', // $id
        'mu Address', // $title
        'show_mu_address_meta_box', // $callback
        'post', // $screen
        'advanced', // $context
        'high' // $priority
    );
}



function show_mb_address_meta_box() {
    global $post;  
        $meta = get_post_meta( $post->ID, 'your_fields', true ); ?>

    <input type="hidden" name="your_meta_box_nonce" value="<?php echo wp_create_nonce( basename(__FILE__) ); ?>">

            <?php }

I have two wordpress sites:

  1. running on localhost server (PHP7.3)
  2. hosted on Bluehost (PHP7.2)

The metabox gets added on my local website, but the same piece of code does not work on bluehosted website.

What is wrong?

add_action( 'add_meta_boxes', 'add_mu_address_meta_box' );

function add_mu_address_meta_box() {
    add_meta_box(
        'your_fields_meta_box', // $id
        'mu Address', // $title
        'show_mu_address_meta_box', // $callback
        'post', // $screen
        'advanced', // $context
        'high' // $priority
    );
}



function show_mb_address_meta_box() {
    global $post;  
        $meta = get_post_meta( $post->ID, 'your_fields', true ); ?>

    <input type="hidden" name="your_meta_box_nonce" value="<?php echo wp_create_nonce( basename(__FILE__) ); ?>">

            <?php }
Share Improve this question edited Sep 23, 2019 at 2:05 Morgan Janjua Crane asked Jan 23, 2019 at 16:07 Morgan Janjua CraneMorgan Janjua Crane 55 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0
add_action( 'add_meta_boxes', 'add_mu_address_meta_box' );

function add_mu_address_meta_box() {
$screens = array( 'post', 'page' );
    add_meta_box(
        'your_fields_meta_box','mu Address','show_mb_address_meta_box',$screens,'advanced','high' 
    );
}
发布评论

评论列表(0)

  1. 暂无评论