Close Menu
My SiteMy Site
  • Home
  • Reviews
  • Computers
  • How Tos
  • Travel & Lifestyle
  • Phone ROMs
  • Contact
    • Advertise
    • About Us
Facebook X (Twitter) Instagram
My SiteMy Site
  • Home
  • Reviews
  • Computers
  • How Tos
  • Travel & Lifestyle
  • Phone ROMs
  • Contact
    • Advertise
    • About Us
My SiteMy Site
Home»Web Design Tips»Wordpress»How to Display Different Excerpt Length in Different Categories in WordPress
Wordpress

How to Display Different Excerpt Length in Different Categories in WordPress

Oscar FrankBy Oscar Frank2 Mins Read
Share
Facebook Twitter LinkedIn WhatsApp Pinterest Email

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.

  • Read: How to Display Post Excerpts in WordPress Themes

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
    • Read: How to Get A specific Category ID in WordPress
  • 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.

Wordpress Wordpress theme wordpress tips

Related Posts

WordPress Blog Hosting made easy with SeekaHost Blog Hosting Control Panel

December 4, 2020

How to Create a Website with Elementor Page Builder in WordPress

April 1, 2019

Top 3 Reasons Backing Up Your Files Offsite Is Extremely Important

February 27, 2018
View 1 Comment

1 Comment

  1. Omoluabipoint on August 5, 2018 1:36 am

    I wish you should share with us exactly way to do that stuff for blogger blog.

    Reply
Leave A Reply Cancel Reply

Recent Posts
  • 6 Sports Apps You Must Have On Your Phone
  • Valencia Travel Guide: All You Need to Know About This Spanish Gem
  • TikTok Faces Unexpected Ban in Senegal, Sparks Global Curiosity
  • The Apple GPT & Apple’s Chatbot Mysterious Debut
  • Triller Takes on TikTok: Filing for Public Listing
Get Exclusive Tech Insights!
My Site
Facebook X (Twitter) Instagram YouTube
© 2025 Oscarmini Co. Designed by illBytes.

Type above and press Enter to search. Press Esc to cancel.