How to Change Posts Label and All Admin Menu Labels In WordPress

When creating a WordPress powered website for a client you may find that the default WordPress admin navigation menu label of Posts can be confusing when the client is attempting to create news content. A more suitable replacement menu label to use instead of Posts and one which a client should instantly recognise is Articles or News.

How to Change Posts Label and All Admin Menu Labels In WordPress

How to Change Posts Label and All Admin Menu Labels In WordPress

This change is quite easy to achieve by using a few simple WordPress filters and functions which you can copy and paste into your themes functions.php file.

add_filter('gettext',  'change_post_to_article');
add_filter('ngettext',  'change_post_to_article');
 
function change_post_to_article($translated) {
     $translated = str_ireplace('Post',  'Article',  $translated);
     return $translated;
}

The above code will replaces all keyword “Post” to “Article”.

Change Posts Menu To Article

This snippet will change the post in the menu to the Articles it will also get the sub-menus and change the labels to go from posts to articles.

/**
 * Change the post menu to article
 */
function change_post_menu_text() {
  global $menu;
  global $submenu;
  // Change menu item
  $menu[5][0] = 'Articles';

  // Change post submenu
  $submenu['edit.php'][5][0] = 'Articles';
  $submenu['edit.php'][10][0] = 'Add Articles';
  $submenu['edit.php'][16][0] = 'Articles Tags';
}
add_action( 'admin_menu', 'change_post_menu_text' );

Change Post Labels To Article

When you add a new post there is a header saying add post this snippet will change it to new Article. This will also change all the places post comes up and change it to article.

/**
 * Change the post type labels
 */
function change_post_type_labels() {
  global $wp_post_types;
  // Get the post labels
  $postLabels = $wp_post_types['post']->labels;
  $postLabels->name = 'Articles';
  $postLabels->singular_name = 'Articles';
  $postLabels->add_new = 'Add Articles';
  $postLabels->add_new_item = 'Add Articles';
  $postLabels->edit_item = 'Edit Articles';
  $postLabels->new_item = 'Articles';
  $postLabels->view_item = 'View Articles';
  $postLabels->search_items = 'Search Articles';
  $postLabels->not_found = 'No Articles found';
  $postLabels->not_found_in_trash = 'No Articles found in Trash';
}
add_action( 'init', 'change_post_type_labels' );

But you can also change the labels of any post type or media item you have installed on your WordPress site. You can use the above code to change the Pages label or the Media labels.

Change Page Labels

/**
 * Change the pages labels
 */
function change_pages_labels() {
  global $wp_post_types;
  // Get the post labels
  $pageLabels = $wp_post_types['page']->labels;
}
add_action( 'init', 'change_pages_labels' );

Change Media Labels

/**
 * Change the media labels
 */
function change_media_labels() {
  global $wp_post_types;
  // Get the post labels
  $pageLabels = $wp_post_types['attachment']->labels;
}
add_action( 'init', 'change_media_labels' );

Change All Admin Menu Labels

I have seen the best wordpress plugin to accomplish this task is Admin Menu Editor. You will need to play around with this plugin to change the labels in wordpress admin panel interface. Admin Menu Editor lets you manually edit the Dashboard menu. You can reorder the menus, show/hide specific items, change access rights, and more.

Change All Admin Menu Labels

Admin Menu Editor lets you manually edit the Dashboard menu

There is another solution for you, which is installing a wordpress language package and edit the language file. Let me know the best way for you by commenting.

Leave a Reply

avatar
  Subscribe  
Notify of