When setting up meta boxes in a custom post type I’ve been do so using the add_meta_boxes
hook, e.g.
add_action('add_meta_boxes', 'meta_box_setup');
function meta_box_setup()
{
add_meta_box(
'mb_movie_review',
'Movie Review Details',
'display_movie_review_mb',
'movie-reviews',
'side',
'high'
);
}
But I’ve just read this tutorial which does the following using the admin_init
hook, like so…
add_action('admin_init', 'meta_box_setup');
function meta_box_setup()
{
add_meta_box(
'mb_movie_review',
'Movie Review Details',
'display_movie_review_mb',
'movie-reviews',
'side',
'high'
);
}
This is the first time I’ve seen it done using the admin_init
hook.
Question
The latter method (using admin_init
) does work but …
- is this the preferred method? (i.e. more optimized?)
- just a different way of achieving the same results, or
- a bad way to add meta boxes? (if so, why?)