Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13305 closed enhancement (wontfix)

Allow multiple post types to use same add_meta_box call (Pass an array for the $page arg)

Reported by: idealien Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:


The $page parameter of add_meta_box http://codex.wordpress.org/Function_Reference/add_meta_box currently only accepts a string to "The type of Write screen on which to show the edit screen section ('post', 'page', or 'link')".

In discussing best way to allow for multiple post types to use the same meta box with 3.0 (beta), scribu indicated that currently one would have to call add_meta_box twice.

scibu: come to think of it, you should be able to pass an array for the $page arg

Change History (8)

comment:1 idealien4 years ago

  • Cc idealien added

comment:2 idealien4 years ago

  • Milestone changed from Unassigned to 3.1

comment:3 scribu4 years ago

  • Keywords > 3.0 removed

comment:4 scribu4 years ago

  • Type changed from defect (bug) to enhancement

comment:5 kevinB4 years ago

  • Cc kevinB added

comment:6 nacin4 years ago

Should be simple enough to check if $page is an array, and if so, call add_meta_box again with the same parameters otherwise.

Related: #13937

comment:7 markjaquith4 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Just leverage the variables passed to the do_meta_boxes callback.

function your_callback( $page, $context ) {
    if ( in_array( $page,  array( 'post', 'page' ) ) && 'normal' == $context )
        add_meta_box( 'your-id', 'Title', 'your_box_callback', $page, $context, 'high' );

add_action( 'do_meta_boxes', 'your_callback', 10, 2 );

comment:8 nacin4 years ago

  • Milestone Awaiting Triage deleted
Note: See TracTickets for help on using tickets.