Is there a way to take the global $wp_meta_boxes variable to be used in the front-end? Currently the $wp_meta_boxes is accessible on specific admin pages only.

I've found a similar question about this. Its solution is to get the data via the do_meta_boxes hook, but I would like to access the variable without JS/AJAX, and in a front-end template.

  • Can I ask why do you need that?
    – cybmeta
    Mar 23, 2016 at 8:38
  • 1
    TBH, I forgot why I need this Mar 23, 2016 at 9:10

1 Answer 1


I'm afraid you can't do what you are after - without AJAX, that is.

The problem lies with the fact that all/most of the meta boxes are added in an admin-specific context.

The add_meta_boxes action hook, for instance, is the most common (and appropriate) place to add custom meta boxes. And this very hook is fired in only three wp-admin files/pages.

And even if you think about firing the above action on the front-end by yourself, you can't get a hold of all those meta boxes that are added in an admin context only.

I, for myself, add custom meta boxes like so:

if ( is_admin() ) {
    add_action( 'add_meta_boxes', 'wpdev_154684_add_my_custom_meta_box' );

function wpdev_154684_add_my_custom_meta_box() {

        /* ... */

Of course, this is a strong simplification/abstraction of how the code actually looks like.

So, what then?

Since you linked to my question, I think you already found one way of getting admin-specific stuff - from somewhere other than the actual context.

I'm definitely not saying this is the only way. This is just what I came up with (with all the help from Shazzad and G.M.), for my very special context.

  • thanks for your respond, I'm actually still trying to find any hacky solution for this ( almost giving up :( ), for example using wp_remote_get, or include the hook on the template, still no luck so far. Jul 17, 2014 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.