Wordpress Excerpt box label customisation

How To Change Excerpt Box Label in WordPress?

Published on July 27th, 2017




WordPress provides an excellent feature – the Excerpt- which shows a stripped down version of the post, generated automatically where it counts fixed number of words/characters from the post and displays it. For a more meaningful summary, you can enter the excerpt manually as well in the Excerpt box provided.

Default Excerpt box text label

First of all, make sure the Excerpt box is visible on the Add/Edit page. The Admin can show/hide the Excerpt box by checking/unchecking the Excerpt box from the Screen Options slide-open section. WordPress provides Screen Options to manage the display of sections on the Add/Edit page and it is placed on the top right of the page.

Excerpt check box in the WordPress Admin

Many times, you require the functionality of the Excerpt, however, you do not want it to be called Excerpt but some other name for better understanding. You can also create a new custom field for your requirements, however, why create a new field when you can use the existing fields. For instance, for one of our clients, we had to change it to “Citation” which they wanted to manually enter for every article they will publish.

WordPress provides a way to change the default field labels using filter hooks – gettext. The code to change the Excerpt label is below for you to understand and use. Add this code in the functions.php file of your theme. Line number highlighted in green is where you enter your own text label and info text respectively.

add_filter( 'gettext', 'wpse22764_gettext', 10, 2 );

function wpse22764_gettext( $translation, $original )
{
    if ( 'Excerpt' == $original ) 
        {
             return 'Citation'; //Change here to what you want Excerpt box to be called
        }else
        {
             $pos = strpos($original, 'Excerpts are optional hand-crafted summaries of your');
        
              if ($pos !== false) 
              {
                  return  'My Excerpt description here'; //Change the default text you see below the box with link to learn more...
              }
        }
    return $translation;
}

One thing to remember is that there is no change in the way you use the excerpt function (get_excerpt() function) to display the content on the front. Below is how you see the new text – ‘Citation’ in place of the Excerpts text.

Changed Excerpt box label into citation label in WordPress admin

Although it’s a small fix, it is a handy wordpress admin customisation to suit your clients’ needs.

How To Change Excerpt Box Label in WordPress? was last modified: July 27th, 2017 by Curative Nature

Leave a Reply

Your email address will not be published. Required fields are marked *