UK Support 01392 914033 Offices are currently closed

Changing Summary Length in WordPress

4th May 2010 Web Design, Wordpress

<![CDATA[

With millions of individuals and businesses worldwide using open source content management systems (CMS) for their websites there’s a definite trend of frequently asked questions being emailed into the Media Street website design office. As a result we’re starting a new category to deal with common problems and questions when it comes to WordPress. This is the first question we’re answering.

As we’ve all probably seen, WordPress has a summary facility to shorten content so as to use it in search results, headline news etc. this is what’s called an excerpt. This excerpt has a default setting of two paragraphs. How do we change it though and what is the code exactly?

Customising the Size of the Excerpt

  1. Log in and go to the dashboard of your WordPress website.
  2. In the side menu go to ‘Appearance’ and choose ‘editor’.
  3. Now select your functions.php file and open it to edit.
  4. Find the bottom of the page and place this in

add_filter(‘excerpt_length’, ‘my_excerpt_length’);
function my_excerpt_length($length) {
return 30; }

NB: 30 is the number of words in the summary / excerpt. Change this as you wish.

Using the Excerpt Feature in Templates

Now that you’ve got the summary feature customised and available for use, why not go ahead and enter it on to a template within the WordPress loop area of the template. Below is an example of the WordPress Loop which is integrated with the Excerpt facility.



 

<a

Facebook Twitter LinkedIn Email