Admin Area

Change Posts Labels In WordPress

Now that WordPress has all the capabilities you need from a CMS, many people say that they want WordPress to stop acting like a blog platform and more like a CMS.

There are lots of ways they can do this one is by making it easy in the admin screen to create custom post types, to easily be able to customise the data.

Another way is to to remove the word posts from the admin screen and replace this with the word article, in this tutorial you will learn how to do exactly that.

posts_to_articles

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' );
Back to top

Fastest WordPress Hosting With WPEngine

Stunning speed, powerful security, and best-in-class customer service. At WP Engine.

Risk free for 60 days