Custom Fields
Support General rwmb_get_registry() in network context

  • Creator
  • #18040

    Hi everyone,

    I'm trying to use rwmb_get_registry() to get all the id of my differents meta_boxes in a network context. But all i can print is the array of blog_id 1, not the second one (that uses a different themes)

    My metabox AIO is up to date, and i call various meta boxes from php files

    $theme = wp_get_theme();
    print_r($theme->name);//good theme name so i'm sure i've switch
    $meta_box_registry = rwmb_get_registry('meta_box');
    $meta_boxes = $meta_box_registry->all();
    print_r($meta_boxes);//print metaboxes array from blog_id 1

    Any clues ?

    Thanks for your help

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #18048
    Anh Tran

    Hi Kevin,

    The meta boxes are added to the registry at init hook with priority = 20. Can you try to run the code after that?


    Hi Anh,

    My code is called out of the box, as you may have noticed with wp-load.php being require on top of it.
    I am trying to get all fields IDs declared in several $meta_boxes to get all values for a specific post and child posts to create an excel export of it.

    Seems to work fine on a single install of wordpress, problem is the network is calling only the blog_id 1, even with the switch_to_blog(2) before my code.

    so i am pretty sure that the code is called after priority 20.

    Still trying to figure it out, but if you have any idea, that would be great 🙂

    thanks for your help,

    Anh Tran

    Hi Kevin,

    I've just tested and found that the wp-load.php file loads everything and thus, runs all necessary actions, including the init. That means when including that file, the init action is already fired, and meta boxes are registered. When switching to another site in the network, we simply switch the options/configure/themes, etc. and the actions are not triggered again.

    I'm not sure if there's a way to change that behavior. I don't have a solution for that at the moment. I'm very sorry.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.