admin管理员组文章数量:1416325
I'm adding a meta box to a WordPress admin page.
It works fine on my local server but when I upload it to the live server, the meta box doesn't appear.
Its does however appear in the screen options, so I know the code is working to some extent but it's just not displaying anything on the edit page.
I've uninstalled all the plugins and that didn't equally solve the issue.
Below is my code:
function ila_add_custom_box() {
add_meta_box(
'content-on-page',
'Content On Page',
'ila_render_meta_box',
'page',
'high'
);
}
add_action( 'add_meta_boxes', 'ila_add_custom_box' );
function ila_render_meta_box() {
echo "<h1>Edit Page Options</h1>";
}
How can I resolve it?
I'm adding a meta box to a WordPress admin page.
It works fine on my local server but when I upload it to the live server, the meta box doesn't appear.
Its does however appear in the screen options, so I know the code is working to some extent but it's just not displaying anything on the edit page.
I've uninstalled all the plugins and that didn't equally solve the issue.
Below is my code:
function ila_add_custom_box() {
add_meta_box(
'content-on-page',
'Content On Page',
'ila_render_meta_box',
'page',
'high'
);
}
add_action( 'add_meta_boxes', 'ila_add_custom_box' );
function ila_render_meta_box() {
echo "<h1>Edit Page Options</h1>";
}
How can I resolve it?
Share Improve this question edited Jun 11, 2017 at 15:35 nyedidikeke 4921 gold badge6 silver badges15 bronze badges asked Jan 30, 2014 at 14:49 danbrowndanbrown 5721 gold badge8 silver badges18 bronze badges 02 Answers
Reset to default 4You missed one argument in the $args
for add_meta_box
.
The correct use would be (Codex):
add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );
You forgot to set the context
, add it and you should be fine.
add_meta_box(
'content-on-page',
'Content On Page',
'ila_render_meta_box',
'page',
'normal', // add this line
'high'
);
The correct code
$screens = array( 'post', 'page' )
add_meta_box(
'your_fields_meta_box', // $id
'Your Fields', // $title
'show_your_fields_meta_box', // $callback
$screens , // $screen
'normal', // $context
'high' // $priority
);
本文标签: metaboxAddmetabox not appearingbut does appear in screen options
版权声明:本文标题:metabox - Add_meta_box not appearing, but does appear in screen options 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745251710a2649862.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论