i want to display the list of all the meta boxes of each post. the global variable wp_meta_boxes would not print anything on the screen. how can i print the value of the array to get the list of all metaboxes details.
<?php
global $wp_meta_boxes;
pr(wp_meta_boxes);
?>
But the screen is empty doesn't print anything.
i want to display the list of all the meta boxes of each post. the global variable wp_meta_boxes would not print anything on the screen. how can i print the value of the array to get the list of all metaboxes details.
<?php
global $wp_meta_boxes;
pr(wp_meta_boxes);
?>
But the screen is empty doesn't print anything.
All the meta boxes are kept in a multidimensional array, called $wp_meta_boxes. It will display all of the meta boxes registered for a specific screen and a specific context.
Use the following code:
function get_meta_boxes( $screen = null, $context = 'advanced' ) {
global $wp_meta_boxes;
if ( empty( $screen ) )
$screen = get_current_screen();
elseif ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
$page = $screen->id;
return $wp_meta_boxes[$page][$context];
}
Now, if you want to get an array that contains all of the meta boxes that are of "normal" priority, you have to use the following code:
$dashboard_boxes = get_meta_boxes( 'dashboard', 'normal' );
do_action( 'add_meta_boxes_post', $post );
(or change 'post' in the action name to some other post type) but only in classes that start withedit
, and that's what populates $wp_meta_boxes. What exactly do you want to find - the contents of a particular box for a post? – Rup Commented Dec 29, 2018 at 8:42