WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know how to add fields to custom post types one at a time.

I was wondering if there is a way to add a field to the default post type as well as all the custom post types at once?


share|improve this question
up vote 1 down vote accepted

You can't use the add_meta_box() function with an array of post types unfortunately although it would be a good core contribution.

The way to do this at the moment is to get an array of your post types and loop over them calling your add_meta_box() line for each one eg:

foreach( get_post_types() as $type ) {
    add_meta_box( $id, $title, $callback, $type, $context, $priority, $callback_args );

You can filter the specific post types you get back if you need more control by passing an array into get_post_types() with the post type criteria you want to match eg. 'public' => true.

share|improve this answer
That's what I thought as well. It would be useful to be use a hook to inject meta boxes when you create a custom post type. – cbaigorri Sep 21 '11 at 18:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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