Skip to main content
fixed typo
Source Link

You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is run prior.

You can see an example of this in /wp-admin/edit-form-comment.php...

do_action( 'add_meta_boxes', 'comment', $comment );
do_action( 'add_meta_boxes_comment', $comment );
do_meta_boxes( null, 'normal', $comment );

They ran two do_actions() but you can just use one if needed and it can be something custom like do_action( 'add_meta_boxes_banner', $someArgumentIfNeeded ). Basically, with your current code the add_meta_box action is never being triggered because the custom page doesn't run a do_action() for it.

For the JS sortability and expand/collapse you will also want to make sure to enqueue post.js. You will need post.js and postbox.js (the laterlatter of which will come along with post.js) which you can enqueue like this...

wp_enqueue_script( 'post' );

And wrap your output somewhere with the class metabox-holder on a parent div to fix some broken styles...

You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is run prior.

You can see an example of this in /wp-admin/edit-form-comment.php...

do_action( 'add_meta_boxes', 'comment', $comment );
do_action( 'add_meta_boxes_comment', $comment );
do_meta_boxes( null, 'normal', $comment );

They ran two do_actions() but you can just use one if needed and it can be something custom like do_action( 'add_meta_boxes_banner', $someArgumentIfNeeded ). Basically, with your current code the add_meta_box action is never being triggered because the custom page doesn't run a do_action() for it.

For the JS sortability and expand/collapse you will also want to make sure to enqueue post.js. You will need post.js and postbox.js (the later of which will come along with post.js) which you can enqueue like this...

wp_enqueue_script( 'post' );

And wrap your output somewhere with the class metabox-holder on a parent div to fix some broken styles...

You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is run prior.

You can see an example of this in /wp-admin/edit-form-comment.php...

do_action( 'add_meta_boxes', 'comment', $comment );
do_action( 'add_meta_boxes_comment', $comment );
do_meta_boxes( null, 'normal', $comment );

They ran two do_actions() but you can just use one if needed and it can be something custom like do_action( 'add_meta_boxes_banner', $someArgumentIfNeeded ). Basically, with your current code the add_meta_box action is never being triggered because the custom page doesn't run a do_action() for it.

For the JS sortability and expand/collapse you will also want to make sure to enqueue post.js. You will need post.js and postbox.js (the latter of which will come along with post.js) which you can enqueue like this...

wp_enqueue_script( 'post' );

And wrap your output somewhere with the class metabox-holder on a parent div to fix some broken styles...

added 113 characters in body
Source Link

You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is run prior.

You can see an example of this in /wp-admin/edit-form-comment.php...

do_action( 'add_meta_boxes', 'comment', $comment );
do_action( 'add_meta_boxes_comment', $comment );
do_meta_boxes( null, 'normal', $comment );

They ran two do_actions() but you can just use one if needed and it can be something custom like do_action( 'add_meta_boxes_banner', $someArgumentIfNeeded ). Basically, with your current code the add_meta_box action is never being triggered because the custom page doesn't run a do_action() for it.

For the JS sortability and expand/collapse you will also want to make sure to enqueue post.js. You will need post.js and postbox.js (the later of which will come along with post.js) which you can enqueue like this...

wp_enqueue_script( 'post' );

And wrap your output somewhere with the class metabox-holder on a parent div to fix some broken styles...

You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is run prior.

You can see an example of this in /wp-admin/edit-form-comment.php...

do_action( 'add_meta_boxes', 'comment', $comment );
do_action( 'add_meta_boxes_comment', $comment );
do_meta_boxes( null, 'normal', $comment );

They ran two do_actions() but you can just use one if needed and it can be something custom like do_action( 'add_meta_boxes_banner', $someArgumentIfNeeded ). Basically, with your current code the add_meta_box action is never being triggered because the custom page doesn't run a do_action() for it.

For the JS sortability and expand/collapse you will also want to make sure to enqueue post.js. You will need post.js and postbox.js (the later of which will come along with post.js) which you can enqueue like this...

wp_enqueue_script( 'post' );

You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is run prior.

You can see an example of this in /wp-admin/edit-form-comment.php...

do_action( 'add_meta_boxes', 'comment', $comment );
do_action( 'add_meta_boxes_comment', $comment );
do_meta_boxes( null, 'normal', $comment );

They ran two do_actions() but you can just use one if needed and it can be something custom like do_action( 'add_meta_boxes_banner', $someArgumentIfNeeded ). Basically, with your current code the add_meta_box action is never being triggered because the custom page doesn't run a do_action() for it.

For the JS sortability and expand/collapse you will also want to make sure to enqueue post.js. You will need post.js and postbox.js (the later of which will come along with post.js) which you can enqueue like this...

wp_enqueue_script( 'post' );

And wrap your output somewhere with the class metabox-holder on a parent div to fix some broken styles...

Added info about including JS functionality
Source Link

You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is run prior.

You can see an example of this in /wp-admin/edit-form-comment.php...

do_action( 'add_meta_boxes', 'comment', $comment );
do_action( 'add_meta_boxes_comment', $comment );
do_meta_boxes( null, 'normal', $comment );

They ran two do_actions() but you can just use one if needed and it can be something custom like do_action( 'add_meta_boxes_banner', $someArgumentIfNeeded ). Basically, with your current code the add_meta_box action is never being triggered because the custom page doesn't run a do_action() for it.

For the JS sortability and expand/collapse you will also want to make sure to enqueue post.js. You will need post.js and postbox.js (the later of which will come along with post.js) which you can enqueue like this...

wp_enqueue_script( 'post' );

You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is run prior.

You can see an example of this in /wp-admin/edit-form-comment.php...

do_action( 'add_meta_boxes', 'comment', $comment );
do_action( 'add_meta_boxes_comment', $comment );
do_meta_boxes( null, 'normal', $comment );

They ran two do_actions() but you can just use one if needed and it can be something custom like do_action( 'add_meta_boxes_banner', $someArgumentIfNeeded ). Basically, with your current code the add_meta_box action is never being triggered because the custom page doesn't run a do_action() for it.

You can implement meta boxes on other non-post_type admin pages but you need to manually call do_meta_boxes() where you want them to output. You also need to make sure that add_meta_box() action is run prior.

You can see an example of this in /wp-admin/edit-form-comment.php...

do_action( 'add_meta_boxes', 'comment', $comment );
do_action( 'add_meta_boxes_comment', $comment );
do_meta_boxes( null, 'normal', $comment );

They ran two do_actions() but you can just use one if needed and it can be something custom like do_action( 'add_meta_boxes_banner', $someArgumentIfNeeded ). Basically, with your current code the add_meta_box action is never being triggered because the custom page doesn't run a do_action() for it.

For the JS sortability and expand/collapse you will also want to make sure to enqueue post.js. You will need post.js and postbox.js (the later of which will come along with post.js) which you can enqueue like this...

wp_enqueue_script( 'post' );
Source Link
Loading