The function register_post_type() takes an argument 'labels'
. This is an array, one of the possible keys is named … tada! … 'menu_name'
.
Sample code
register_post_type(
'academias'
, array (
'can_export' => TRUE
, 'exclude_from_search' => FALSE
, 'has_archive' => TRUE
, 'hierarchical' => TRUE
, 'label' => 'Academias'
, 'labels' => array ( 'menu_name' => 'See All Academias' )
, 'menu_position' => 5
, 'public' => TRUE
, 'publicly_queryable' => TRUE
, 'query_var' => 'academias'
, 'rewrite' => array ( 'slug' => 'academias' )
, 'show_ui' => TRUE
, 'show_in_menu' => TRUE
, 'show_in_nav_menus' => TRUE
, 'supports' => array ( 'editor', 'title' )
)
);
Update
Now, that I’ve understood your question better, there seems to be only one way to accomplish what you want: hook into attribute_escape
.
Test Plugin
<?php
/*
Plugin Name: *WPSE13210
*/
! defined( 'ABSPATH' ) and exit;
add_action( 'init', 'register_academia' );
/**
* Registers te post type academias
*
* @return void
*/
function register_academia()
{
register_post_type(
'academias'
, array (
'can_export' => TRUE
, 'exclude_from_search' => FALSE
, 'has_archive' => TRUE
, 'hierarchical' => TRUE
, 'label' => 'Academias'
, 'labels' => array (
'menu_name' => 'See All Academias'
, 'name' => 'Academias'
)
, 'menu_position' => 5
, 'public' => TRUE
, 'publicly_queryable' => TRUE
, 'query_var' => 'academias'
, 'rewrite' => array ( 'slug' => 'academias' )
, 'show_ui' => TRUE
, 'show_in_menu' => TRUE
, 'show_in_nav_menus' => TRUE
, 'supports' => array ( 'editor', 'title' )
)
);
}
add_filter( 'attribute_escape', 'rename_second_menu_name', 10, 2 );
/**
* Renames the first occurence of 'See All Academias' to 'Academias'
* and deactivates itself then.
* @param $safe_text
* @param $text
*/
function rename_second_menu_name( $safe_text, $text )
{
if ( 'See All Academias' !== $text )
{
return $safe_text;
}
// We are on the main menu item now. The filter is not needed anymore.
remove_filter( 'attribute_escape', 'rename_second_menu_name' );
return 'Academias';
}
Not very elegant, but at least a solution …
Update 12.05.2010
In ticket 17378 a new parameter all_items
was proposed. That should work much better, once it’s part of the core …