Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 12 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: Posts, Post Types Version:
Severity: normal Keywords:
Cc: Focuses:

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 (9)

#1 @idealien
16 years ago

  • Cc idealien added

#2 @idealien
16 years ago

  • Milestone Unassigned → 3.1

#3 @scribu
16 years ago

  • Keywords > 3.0 removed

#4 @scribu
16 years ago

  • Type defect (bug) → enhancement

#5 @kevinB
16 years ago

  • Cc kevinB added

#6 @nacin
16 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

#7 @markjaquith
16 years ago

  • Resolution → wontfix
  • Status new → 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 );

#8 @nacin
16 years ago

  • Milestone Awaiting Triage

This ticket was mentioned in IRC in #wordpress-dev by SergeyBiryukov. ​View the logs.


12 years ago

Note: See TracTickets for help on using tickets.