Skip to content

Instantly share code, notes, and snippets.

@michaelschofield
Created August 2, 2013 16:51
Show Gist options
  • Save michaelschofield/6141445 to your computer and use it in GitHub Desktop.
Save michaelschofield/6141445 to your computer and use it in GitHub Desktop.
User-Friendly Labeling for WP Custom Post Type
/* ==================
* User-Friendly Labeling
*/ // Sometimes you don't want to remove, say, the editor
// from the post-type, but maybe you just want to
// call it something different.
function post_type_label_rewrite( $translation, $text, $domain ) {
global $post;
if ( !isset( $post->post_type ) ) { return $translation; }
$translations = &get_translations_for_domain($domain);
$translation_array = array();
switch ( $post->post_type ) {
case 'custom_post_type': // Enter the post-type slug here
$translation_array = array(
'Excerpt' => 'A brief, friendly summary.'
);
break;
}
if ( array_key_exists( $text, $translation_array ) ) { return $translations->translate( $translation_array[$text] ); }
return $translation;
}
add_filter('gettext', 'library_academy_label_rewrite', 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment