Skip to content

Instantly share code, notes, and snippets.

@westcoastdigital
Created October 28, 2021 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westcoastdigital/faa7fd02af5f1320ed397ad2d5fb3dfa to your computer and use it in GitHub Desktop.
Save westcoastdigital/faa7fd02af5f1320ed397ad2d5fb3dfa to your computer and use it in GitHub Desktop.
Change the WordPress Category name and text on the admin screen
<?php
/**
* Change core category to Channel
*/
if( !function_exists('wcd_rename_category_theme') ) {
function wcd_rename_category_theme() {
$singular_name = 'Channel';
$plural_name = 'Channels';
$labels = array(
'name' => $plural_name,
'menu_name' => $plural_name,
'singular_name' => $singular_name,
'search_items' => 'Search ' . $plural_name,
'popular_items' => 'Popular ' . $plural_name,
'all_items' => 'All ' . $plural_name,
'parent_item' => 'Parent ' . $singular_name,
'parent_item_colon' => 'Parent ' . $singular_name . ':',
'edit_item' => 'Edit ' . $singular_name,
'view_item' => 'View ' . $singular_name,
'update_item' => 'Update ' . $singular_name,
'add_new_item' => 'Add New ' . $singular_name,
'new_item_name' => 'New ' . $singular_name . ' Name',
'separate_items_with_commas' => 'Separate ' . $plural_name . ' with commas',
'add_or_remove_items' => 'Add or remove ' . $plural_name,
'back_to_items' => '← Back to ' . $plural_name,
'items_list_navigation' => $plural_name . ' list navigation',
'items_list' => $plural_name . ' list',
);
global $wp_taxonomies;
$wp_taxonomies['category']->labels = (object) array_merge( (array) $wp_taxonomies['category']->labels, $labels );
}
add_action( 'init', 'wcd_rename_category_theme' );
}
if( !function_exists('wcd_rename_category_theme') ) {
function humaan_change_category_name_description( $translated_text ) {
global $current_screen;
if ($current_screen && $current_screen->taxonomy === 'category') {
switch ( $translated_text ) {
case 'The name is how it appears on your site.' :
$translated_text = 'Channel links will wrap at one word per line. Try to keep the name to approx. 3 words long.';
break;
}
}
return $translated_text;
}
add_filter( 'gettext', 'wcd_change_category_name_description', 20, 3 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment