Skip to main content

WordPress – Change Post Excerpt Length

Submitted by admin on Fri, 12/10/2021 - 22:32

Default WordPress Post Excerpt Length

By default excerpt length of posts is set to return 55 words. But you may wish to change this value. In this tutorial, I will explain how to change the post excerpt length in WordPress.

How To Change Post Excerpt Length

Suppose, we want to change the excerpt length to 40 words.
Add following codes in functions.php file of your theme.

* Change the excerpt length to 40 words.
function custom_excerpt_length( $length ) {
  return 40;
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Hope this article was helpful to you.


Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.