Home / admin / Use gettext, ngetext to replace array of words in wp admin
  • How to Use gettext, ngetext to replace array of words in wp admin


    Simple but useful method using gettext, ngetext filter to replace an entire array of words within the wordpress admin. Just update the array key with the item you wish to replace and the array value with the text to replace it with. Add this snippet to the functions.php of your wordpress theme.

    wordpress snippet : PHP

    add_filter(  'gettext',  'wps_translate_words_array'  );
    add_filter(  'ngettext',  'wps_translate_words_array'  );
    function wps_translate_words_array( $translated ) {
         $words = array(
    			// 'word to translate' = > 'translation'
    			'Posts' => 'Article',
    			'Post' => 'Articles',
    			'Pages' => 'Stuffing',
    			'Media' => 'Upload Images',
    			'Links' => 'Blog Roll',
         $translated = str_ireplace(  array_keys($words),  $words,  $translated );
         return $translated;

    ( WordPress codex functions, hooks, in this snippet. )

    gettext, add_filter, wp,
  • Wesam Alalem

    Wow! i didn’t about this before. sometimes for certain scenarios it would be great to rename some WP items, like you did to Posts -> Articles.
    Keep up the great work 😉

    • http://wpsnipp.com Kevin Chard

      Hi Wesam, glad you like the snippet, great if you have a few things within the wordpress admin you want to change. Enjoy the wpsnipp :)

  • Pingback: Never forget your Featured Image Dimensions - WPMU.org()

  • Sam

    Thanks for the great trick wondering if could shed light on the below

    what if i have 7308064.jpg as title how do i go about replacing this to whatever i want

    can i add a shortened link followed by some keywords.

  • Sam

    Also besides from wanting to change 7308064.jpg as post title to anpther words can you please help on telling me how to show images while in edit post mode,
    Note i am a newbie but would like to learn