It is usually fun customizing your WordPress theme to a taste and standard that can be found no where else. This post would be your guide in creating different length of excerpts for different categories in your WordPress blog. Incase you do not know what excerpts are, here is a simple explanation.

What are Excerpts

An excerpt

An excerpt is simple a short statement of part of an article taken from a longer article to be displayed with a link to the article. For instance, lets say you made a post of 500 words, it won’t be advisable to display the full content of the article on homepage or category page, you would have to post an excerpt of maybe the first 50 letters with a READ MORE link back to the post  (just like the image above).

Now this is how to display different excerpt lengths for different categories in wordpress. For instance, if the number of letters returned on my excerpt page is 50 letters, but I want all posts under my blogging category to display 100 letters for excerpt, then this code can come in handy.

How to Display Different Excerpt Length for different Categories

  • Login to your WordPress Dashboard, Now Click on Appearance > Editor.
  • Now click on functions.php from your right sidebar to edit.
  • In the very last line paste this code

    add_filter('excerpt_length', 'my_excerpt_length');
    function my_excerpt_length($length) {
    if(in_category(14)) {
    return 13;
    } else {
    return 60;

  • Now change to the specific CATEGORY ID you wish to display with 14 in the above code, for instance if you want this function to affect only posts on your blogging category, get the ID for you BLOGGING CATEGORY
  • Now change 13 with the length of excerpt letters you would like to use in this category.
  • Click on Update File to Save.

That’s how simple it is, check your blog out for this wonderful effect.



Please enter your comment!
Please enter your name here