WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 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:
Priority: normal Milestone:
Component: Post Types Version:
Severity: normal Keywords:
Cc: idealien, kevinB

Description

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 idealien3 years ago

  • Cc idealien added

comment:2 idealien3 years ago

  • Milestone changed from Unassigned to 3.1

comment:3 scribu3 years ago

  • Keywords > 3.0 removed

comment:4 scribu3 years ago

  • Type changed from defect (bug) to enhancement

comment:5 kevinB3 years ago

  • Cc kevinB added

comment:6 nacin3 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 markjaquith3 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 nacin3 years ago

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