I'm running WP multi-site and I've created a plugin that adds meta boxes to my page and post.

add_meta_box( 'Intro', __('Intro'), 'sewp_post_intro_meta_box', 'post', 'normal', 'high' );
add_meta_box( 'Intro', __('Intro'), 'sewp_post_intro_meta_box', 'page', 'normal', 'high' );

The problem is that this isn't added for my custom post types. Adding another add_meta_box in my plugin isn't an option since it will only be relevant for this customer.

Is there a way to get around this?

2 Answers 2


I'm not sure what you mean by "unknown custom posts", but here is how you'd add a meta box to a number of post types:

$post_types = array(
foreach ($post_types as $post_type)
    add_meta_box('Intro', __('Intro'), 'my_meta_box', $post_type, 'normal', 'high');

If you would like to have different contexts and/or priorities, you have to do it in multiple calls.

If I misunderstood you, please enlighten me.

// Edit
Of course, you could do it the other way around, and exclude post types that you do not want to have this meta box.

$args = array(
    'public' => true,
if (! is_array($post_types = get_post_types($args)))
    $post_types = array();


if (count($post_types))
    foreach ($post_types as $post_type)
        add_meta_box('Intro', __('Intro'), 'my_meta_box', $post_type, 'normal', 'high');

If this isn't what you're looking for either, I'm afraid I have no idea what you would be satisfied with.

You don't want to specify post types, but want some functionality bound to specific post types...

  • This is exactly the solution I'm trying to avoid because I'm using this plugin on all my sites. Some single sites and some multi-sites. Having a bunch of extra post types in the array doesn't make sense for the other sites. So I'm hoping there is a way do add them to "any post types"
    – Steven
    Commented Dec 17, 2013 at 22:30
  • 1
    @Steven what's the difference between "any post types" and "all post types"? Are you just picking a random post type to add this to?
    – Howdy_McGee
    Commented Dec 17, 2013 at 22:38
  • @Steven Please see my edit to the above answer.
    – tfrommen
    Commented Dec 17, 2013 at 22:40
  • @Steven Could you explain why you want to avoid adding metaboxes to custom post types, when in your question you said that the problem was your metaboxes weren't being added to custom post types? I think we're confused what you are asking. Commented Dec 17, 2013 at 23:19
  • Thanks @t-f. The best way would be if there was a way to "tell" my plugin to add custom meta boxes to this new post type (from my theme's functions.php). But I guess I just have to use your first solution for now.
    – Steven
    Commented Dec 18, 2013 at 5:44

You can try NULL or an empty string as the $screen input value:

add_meta_box( 'Intro', 
              $screen = '', 

to add the meta box to any "screenable" post type, because then the default is:

 if ( empty( $screen ) )
     $screen = get_current_screen();

ps: If you need some specific post types or better control, you should use what @t f suggested.

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.