Snippet to add meta box to custom post types, posts, and pages

Snippet to add meta box to custom post types ,  posts and pages. It will also add the default CPT included with WordPress which are “attachment,revision,nav_menu_item” so beware.


$post_types= get_post_types('','names'); 
$posts_separated = implode(",",   $post_types);
 
$screens = array( 'post', 'page',  $posts_separated);
      
    foreach ($screens as $screen) {
    add_meta_box( 'styles', 'hello', 'callback_func', $screen, 'advanced', 'high');
    }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s