Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a feeling this is a bug.

When you create a new custom post type it does not seem possible to modify the first submenu item text. I am referring to the link which allows you to view the post list.

For what I can tell it just seems to be duplicating the name name of the main post type menu which was created.

Does anyone know how to modify this text so that I can have the main menu element says "Articles" and the post list submenu name to say "Manage Articles"?

I was under the impression that "edit_item" would control the text to be displayed in te submenu but for some reason this is not registering.

Here is the code I am currently using:

//////////////////////////////////////////////////////////////////////////////
// CUSTOM POSTTYPE FOR -- ARTICLES  
//////////////////////////////////////////////////////////////////////////////

add_action('init', 'articles');
function articles() {
 register_post_type('articles', array(
  'labels' => array(
   'name'   => __('Articles'),
   'singular_label'  => __('Article'),
   'new_item'   => __('Add Article'),
   'add_new'   => __('Add Article'),
   'add_new_item'  => __('Add Article'),
   'edit'   => __('Edit Article'),
   'edit_item'   => __('Edit Article'),
   'view'   => __('View Article'),
   'view_item'   => __('View Article'),
   'search_items'  => __('Search Articles'),
   'not_found'   => __('No Articles Found'),
   'not_found_in_trash' => __('No Articles Found in Trash'),
   ),
  'supports' => array(
   'thumbnail',
   'title',
   'editor',
   'author',
   'revisions',
   ),
  'rewrite' => array( 
   'slug'   => 'articles', 
   'with_front'   => false,
   ),
  'rewrite'    => true,
  'can_export'    => true,
  'show_ui'    => true,
  'menu_position'   => 3,
  'public'    => true,
  'query_var'    => true,
  'publicly_queryable'  => true,
  'exclude_from_search'  => false,
  'capability_type'   => 'post',
  'hierarchical'   => false,
 ));
 }


add_filter('manage_edit-articles_columns', 'add_new_articles_columns');
function add_new_articles_columns($articles_columns) {
 $new_columns['cb']     = '<input type="checkbox" />';
 $new_columns['article_thumbnail']   = _x('Image', 'column name');
 $new_columns['title']    = _x('Article Title', 'column name');
 $new_columns['article_excerpt']   = _x('Article Excerpt', 'column name');
 $new_columns['article_source']   = _x('Article Source', 'column name');
 $new_columns['author']    = __('Created by');
 $new_columns['date']    = _x('Last Action', 'column name');
 return $new_columns;
 }
add_action('manage_posts_custom_column', 'manage_articles_columns', 10, 2);
function manage_articles_columns($column_name, $id) {
 global $wpdb;
 switch ($column_name) { 
  case 'article_thumbnail':  
   the_post_thumbnail( array(50,50) );
   break; 
  case 'article_excerpt': echo substr(get_the_excerpt(),0,500); 
   break;
  case 'article_source':
         echo get_the_term_list($post->ID, 'content_sources', '', ', ','');
   break;
  default: break;
  }
 }
share|improve this question

2 Answers 2

up vote 1 down vote accepted

Hi @NetConstructor.com:

I think you already asked about this and I gave you an answer that would address this question too:

In that answer I gave you a library you can use to make interacting with the admin menus super easy. Here's what you'd have to do to achieve your stated goal on this question:

<?php
require_once('wp-admin-menu-classes.php');
add_action('admin_menu','my_admin_menu');
function my_admin_menu() {
  rename_admin_menu_section('Articles','Manage Articles');`  
}

P.S. BTW, I noticed there were 4 answers provided on that question which you asked almost a week ago, but you haven't gone back an selected any of the answers as the correct answer. Since you have been here asking a lot of questions I know it's not like you've not been around; please take time to select the best answer for your questions as soon as you have a viable answer otherwise people might become demotivated to keep answering. Something this consider...

share|improve this answer
    
Thanks, I just figured I was missing something or there was a simple one liner without having to use a separate class. Actually kinda strange that when creating a custom post type this option is not available. –  NetConstructor.com Sep 7 '10 at 4:50
    
@NetConstuctor.com: It's helpful to understanding how open-source, or at least WordPress evolves. In many ways the developers are putting things in place for the future. Given they have a goal of 3 releases a year some things are too big to be done all at once. So pieces of functionality get handled but it's not like theoretical a large software company that delivers a "complete" solution all at once (like any of them really do that in reality anyway!) Also may of the team don't realize things are needed until after a new release enables users to try new things. –  MikeSchinkel Sep 7 '10 at 5:56
    
@NetConstuctor.com: That said, WordPress has the best balance between new features and ability to extend it prior to those new features I've ever seen, and I've been coding professionally (on and off) for 25 years. –  MikeSchinkel Sep 7 '10 at 5:58

This is a semantics problem.

'edit_item'   => __('Edit Article'),

This is what is displayed when you edit the article, as in singular, just like the edit post, in the top title. The reason that the 'posts' listing menu item is called 'posts' and not 'edit posts' is because that would be misleading.

You can do more than just edit posts, you can delete and move them around etc. The same is true of pages, or any other type of post you may have. This is why the same field that is used for the section menu is used for the initial submenu item also. There is real logic to it. Having said that there is nothing stopping you from setting 'show_ui' => true, to false and implementing it yourself.

However, if you really did want to edit it for whatever reason, you would need to add a hook to functions.php to process the menu afterwards, by searching for the necessary submenu entry in the array and changing its name.

Something along these lines would do, though it may need some modification:

function edit_menus() {
    global $menu;
    end ($menu);
    while (prev($menu)){
        $value = explode(' ',$menu[key($menu)][0]);
        if(strpos($menu[key($menu)], "menu name" )){
            $menu[key($menu)] = str_replace("menu name", "newmenuname", $menu[key($menu)]);
            break;
        }
    }
}
add_action('admin_menu', 'edit_menus');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.