according to the documentation, it is more correct to change the length of the excerpt using add_filter:
add_filter( 'excerpt_length', function(){
return 10;
});
you can make your own function based on this, like this:
add_filter( 'excerpt_length', 'new_excerpt', 10, 1);
function new_excerpt( $lenth ){
return $length;
});
…
apply_filters( 'excerpt_length', 150 );
Related Posts:
- Modify ‘Read more’ link adding a new class
- How to show video from specific category on sidebar?
- How to disable the_excerpt from one post
- Stop WordPress Wrapping Images In A “P” Tag
- GET the excerpt by ID
- How to get ‘post_content’ without stripping tags?
- How to end the excerpt with a sentence rather than a word?
- Get content from one page and show it on another page
- Removing any and all inline styles from the_content()
- How to disable content pagination?
- Adding a div class or id inside the_content()
- Remove image caption from post excerpt
- Divide Post content into separate divs for every 500 characters (or any other character counts)
- Post content being duplicated by the_content();
- How to add an admin function only to posts, not pages?
- How to customize read more link
- Custom wp_trim_words() function not trimming right
- How can I extract the URL of a link from a post?
- Content editor creating blank paragraphs in spaces and creating   in the_excerpt
- How to add custom content (text/image) at start of content (IN content ie the same line)
- Testing for post title in ‘if/else’ statement returns no content
- How to show post(excerpt) from specific category on wp page?
- How to link up “read more” on excerpts hack from WP Recipies
- Append Text to $post->post_excerpt
- Frontend Post Excerpt field mapping
- Allowing the SoundCloud player to appear in a post excerpt
- Auto Refresh Post List after X seconds
- Display the Content of a Post with qTip2
- How to show a full post, not just an excerpt
- custom post type grid with content in lightbox [closed]
- Get post excerpt and title by specific post ID?
- Custom excerpt length filter doesn’t work
- Display most recent post in full, excerpts of older posts
- Modify WP_Post before processing
- Uppercase first sentence in every post
- Why content_arr[‘extended’] removes paragraph tags?
- Modify Image Source With The_Content Filter?
- How to add pagination in between post and comments?
- Print a message if excerpt is empty after posts have been publish/update!
- Adding the_date inside tags around the_content
- get_the_excerpt() is not working as expected – returns wrong text
- Show the content that is after the excerpt using child theme
- How do I display some posts fully on the homepage, and some as an excerpt only?
- get query() without post content?
- How to show full post?
- How to display excerpt post on hamepage and archive pages?
- Filter only the text in the_content
- How to check if single.php has already called the_post_thumbnail function
- Displaying post excerpt using wpdb query
- The_excerpt() doesn’t parse – how to change that?
- Trying to edit archive.php to only show post extract, with featured image
- Show metabox value last post excerpt, title and link
- Hook for changing excerpt content when excerpt not set
- Change the number of excerpts displayed in search results layout
- the_excerpt is displaying excerpts of every post
- Add div before the first paragraph the_content [closed]
- the_content() Not Grabbing All Content
- Why excerpt is Displaying same in Random Posts list
- content summary of a post disappears If an images added at the beginning of the post. how to solve it?
- WordPress Excerpt Paragraph Limiting
- Adding if statement into the_content()
- Grab value of excerpt_length
- Calling Permalinks With PHP
- why my urdu text is not aligned properly when written in wordpress blog post?
- How do I display main query posts in random order using add_filter
- How to Remove HTML Elements from Post Excerpt?
- How to exclude native lazy loading from first image in post content?
- How to add text before post_excerpt in Gutenberg
- Why is WordPress showing a blank excerpt for just one of my posts?
- Related post not showing table of content
- how can i take wordpress post as embed?
- Moved a website and excerpts don’t work for old posts
- Enable HTML Tags in WordPress Post excerpt
- How to display post excerpt beside post list inside Post of Dashboard
- if CPT content is empty then
- Find post tags words in post content and link them to tag URLs
- Trim excerpt to first paragraph
- Nothing appears using get_the_excerpt() in category.php
- Add review box by function at top or bottom of content
- Post List Widget with custom posts and editing the Read More Link
- Add Image Before Posts Entry Title
- Showing content from WordPress ruins page CSS using WP_Query, without, content does not show
- Show category post with excerpt text
- Add a minimum word count to Excerpt (and how to force Excerpt as a rule for WyPiekacz)
- How can i show only 30% of the “the_content(“More…”)”?
- Using the_excerpt() some posts are truncated and some are not
- Assign custom class to post content images
- the_content() not displaying the full post
- Stripping tag from elements in post
- How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?
- wp trim function not working
- excerpt in template for specific page
- Excerpt all post content Content Same Size without word cutting off
- How add class the_content();?
- Show full post only to loged-in users
- Read more opens attachment
- Displaying Page Title on index.php
- Pulling in post category and children within category
- posts_per_page option limits the number of Gallery items
- Un-highlight Blog Menu Item when Category Menu Item is Selected