In the admin bar an admin can create a new post by using the add new drop down. In there I want to change the label Post
to something else.
How can I do this? I just need the code to make the change in the admin bar as I have the code already to change the Post label everywhere else in the admin section.
Bonus points if you can tell me how to change the order of the labels in the drop down too.
4 Answers
Found my answer including my full solution:
<?php
/*
Plugin Name: Rename Posts to News
Description: Rename built in posts to be called News
Version: 1.0
Author: Scott Cariss @ Philosophy Design
Author URI: http://www.philosophydesign.com
*/
// Not a WordPress context? Stop.
! defined( 'ABSPATH' ) and exit;
add_action( 'init', array ( 'chg_Posts_to_News', 'init' ) );
add_action( 'admin_menu', array ( 'chg_Posts_to_News', 'admin_menu' ) );
class chg_Posts_to_News
{
public static function init()
{
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name="Corporate News";
$labels->singular_name="Corporate News";
$labels->add_new = 'Add Corporate News';
$labels->add_new_item = 'Add Corporate News';
$labels->edit_item = 'Edit Corporate News';
$labels->new_item = 'Corporate News';
$labels->view_item = 'View Corporate News';
$labels->search_items="Search Corporate News";
$labels->not_found = 'No corporate news found';
$labels->not_found_in_trash="No corporate news found in trash";
$labels->name_admin_bar="Corporate News";
}
public static function admin_menu()
{
global $menu;
global $submenu;
$menu[5][0] = 'Corporate News';
$submenu['edit.php'][5][0] = 'Corporate News';
$submenu['edit.php'][10][0] = 'Add Corporate News';
}
}
?>
Just needed change the label $labels->name_admin_bar="Corporate News";
Looking through the function wp_admin_bar_new_content_menu( $wp_admin_bar )
that deals with placing these drop down menu items there are no filters or hooks there that will allow me to change the order so I can only presume its not doable without some JS hacks.