Override / filter Excerpt 55 chars length default

Note : This snippet applies to Customizr version 3.1.x and below. It may not work with version 3.2+. Use with caution on 3.2+ and check the availability and type of the hooks in the Customizr hooks API.

Last Reviewed: 29-Mar-14

WordPress sets a default limit of 55 characters for Excerpts.

You can override this limit by adding this code to your functions.php file in a child theme

Where to copy/paste this code?
We strongly recommend you create a child theme and add this to the Child Theme functions.php.
Download a start-up child theme here.

Remember: you shouldn’t edit the theme’s functions.php.

Change the 200 to whatever you need.


About Dave Bardell

My name is Dave Bardell (@rdellconsulting) and have been supporting the Forum since discovering this wonderful Theme. Have learnt a lot from other Supporters (@acub, @tomaja, @ElectricFeet, in particular). Have a library of snippets I've built up which in adding here, I'll try to acknowledge the original contributor but apologies to any I miss or wrongly attribute. daveb@rdellconsulting.com


6 thoughts on “Override / filter Excerpt 55 chars length default

  • Reply
    Matt Daigle

    Is there a recommended plugin or method of adding CUSTOM excerpt boxes to each page/post where we can type something completely different?

    Thanks a bunch!

    • Reply
      Nicolas

      Hi Matt, in WordPress, there’s a built in custom excerpt for posts (in the post edit screen, you might have to acivate this box in the screen options at the top) that you can use.
      For pages, add the following code to your functions.php file, this will add a custom box to your pages to create custom excerpt :

      Hope this will help

      • Reply
        Matt

        D’oh! *headsmack*

        I knew the functionality was there…but for the life of me couldn’t find it again–I always overlook that screen options tab, and assumed the excerpts must’ve been a function of a previous theme.

        You rock, thanks as always sir.

        -Matt

      • Reply
        Marcus

        Hello Nicholas and Dave. Thank you so much for this beautiful theme and your outstanding support from the Themes and Co team!

        Sorry, but my expertise in PHP is not as good as in CSS. I do need longer excerpts for my pages (more than 200 chars) on the front page. I added Nicolas’s snippet to my child functions.php. Now I have featured text input boxes on front page. Great!. However, they are still limited to 200 chars. So I also added the snippet from Dave. But the featured text limit stays at 200 chars. I need to increase it. Apparently there is no functional connection between the 2 snippets? Is there an easy way to increase my custom featured text length?

        [I hope since this is directly related to your 2 snippets above, I am asking the follow up question in the right place ;-)… ]

        • Reply
          Dave Bardell Post author

          Don’t think the 2 snippets are related – one deals with Excerpts yet you’re talking about Featured Text on Front Page.

          I’d suggest the Forum would be a better place to get a solution for this, with a much wider audience to help fix problems. And please include a link to your Site.

  • Reply
    Marcus

    Hi Dave, thank you for your reply. You are correct. My confusion was about terminology. The meanings of words in WP vernacular is quite specific. However, for the uninitiated newcomers (such as myself), I understand word “excerpt” as in natural (English) language — and that’s quite generic. Regardless, @acub was kind and patient to resolve my issue in this post in the forum.

    Of course, I still wish I could override the max. limit of the truncated feature text on front page programmatically in the child functions.php. But apparently, this cannot be done now. Personally, I am reluctant to hack the actual sources of the theme. It is not the right approach, and so I will live with the limitation of 200 chars for now. @Nikeo assures us that a customizable hook will be provided in the future version. That would be outstanding!

Leave a Comment

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

Do you need to share some code? To display it in a nice looking syntax highlighter, wrap your code between the following tags (css code in this example) : <pre class="lang:css">YOUR CODE</pre> ( possible code language acronyms : css, php, xhtml, javascript, sql)

You may also use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">