Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#13560 closed defect (bug) (fixed)

Add custom taxonomy to Pages admin menu

Reported by: markauk's profile markauk Owned by: nacin's profile nacin
Milestone: 3.0.1 Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: custom taxonomy, page, edit-tags.php
Focuses: Cc:

Description

When adding a custom taxonomy to posts, a submenu is added beneath 'Posts' to allow editing of the taxonomy. However, a menu is not added if the taxonomy is attached to Pages, even though the taxonomy works fine when creating/editing posts.

Adding the following code to wp-admin/menu.php fixes this.

immediately after

$submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' );

(line 110 in 3.0b2)

add

	$i = 15;
	foreach ( $wp_taxonomies as $tax ) {
		if ( ! $tax->show_ui || ! in_array('page', (array) $tax->object_type, true) )
			continue;
		$submenu['edit.php?post_type=page'][$i++] = array( esc_attr($tax->label), $tax->manage_cap, 'edit-tags.php?taxonomy=' . $tax->name );
	}
	unset($tax);

(basically a duplicate of the code earlier in menu.php which adds the edit taxonomy submenu for pages).

Change History (6)

#1 @nacin
15 years ago

  • Milestone changed from Unassigned to 3.0

#2 @ryan
15 years ago

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

(In [14953]) Show taxonomies registered against the page type in the Pages submenus. Props markauk. fixes #13560

#3 @SeyelentEco
15 years ago

  • Keywords custom taxonomy page edit-tags.php added
  • Resolution fixed deleted
  • Status changed from closed to reopened

This fix, is missing the post_type=page parameter when building the edit-tags.php URL. The result is that the edit-tags.php page by default thinks it's editing a Post, so it closes tha Pages menu and opens the Posts menu, and the links to view the Pages assigned to a Taxonomy don't work (since they default to Posts too).

This line:

$submenu['edit.php?post_type=page'][$i++] = array( esc_attr( $tax->labels->name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );

Should be changed to:

$submenu['edit.php?post_type=page'][$i++] = array( esc_attr( $tax->labels->name ), $tax->cap->manage_terms, 'edit-tags.php?post_type=page&taxonomy=' . $tax->name );

As a workaround, you can add a custom hook:

function modify_submenu() {
	global $submenu;
	foreach($submenu['edit.php?post_type=page'] as $key=>$smenu)
	{
		$submenu['edit.php?post_type=page'][$key][2] = $smenu[2].'&post_type=page';
	}
	
}
add_action('admin_head', 'modify_submenu');

#4 @nacin
15 years ago

  • Milestone changed from 3.0 to 3.0.1
  • Owner set to nacin
  • Status changed from reopened to accepted

#5 @nacin
15 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [15423]) Fix admin memu link for tax assigned to pages. props SeyelentEco, fixes #13560 for 3.0.

#6 @nacin
15 years ago

(In [15424]) Fix admin memu link for tax assigned to pages. props SeyelentEco, fixes #13560 for trunk.

Note: See TracTickets for help on using tickets.