The excerpt length is the number of words, not the characters. Assuming that every word is 8 characters long in average, you might want to use this:
function wpdocs_custom_excerpt_length( $length ) {
if( is_front_page() ){
return 50;
} else {
return 100;
}
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
Source : WordPress codex
Related Posts:
- Check if the user has explicitly set an excerpt
- How to override function in functions.php of parent theme?
- Show Video in Excerpt
- When is wp_trim_excerpt() called?
- Stripping shortcode from custom excerpt function
- Remove images from get_the_excerpt
- Custom page template how to check is_page from functions.php?
- display public excerpt for private post
- get_the_excerpt() not returning anything when post has no excerpt
- get excerpt without images
- Allow latex in wordpress excerpt
- How to filter out shortcode when displaying the_excerpt() in the loop?
- Using “Read More” link with custom excerpt
- How to display post content instead of excerpt
- Using Schema with `the_excerpt`
- Custom Post excerpt not working correctly
- Limit length of first excerpt in the loop
- new_excerpt_more link not working properly
- Excerpts are not displayed by a shortcode on category pages
- How to display retweet count and likes in the meta above the excerpt
- Setting a default text for excerpts of a particular category
- Remove links from the_content when using filters wp_trim_excerpt
- Excerpt for pages not showing
- How do I pull excerpts from pages?
- WordPress Excerpt – How to remove the first link using functions.php
- Strip div From Excerpt
- How to change value of variable in theme file with functions.php WordPress?
- first paragraph of the_content as meta description
- Adding Read More to Custom excerpts
- Limit number of characters in different excerpts
- the_excerpt function not showing image
- Appending „read more” to the excerpt conditionally
- Hide disclaimer from summary excerpts
- How to make an If Else on Excerpt Filter
- getExcerpt: Make ellipsis appear only if character limit is reached
- need help with ‘… read more’ excerpt in functions.php
- Excerpt length: get 2 paragraphs
- Check if excerpt is empty at loop-portfolio
- Can’t change excerpt length and more tag
- More link – not text
- How to add an excerpt and read more link to a page?
- Adding a filter to my posts
- Excerpt – First Sentence & Read More
- function to show youtube videos within excerpt – if condition and apply_filters
- How to add a data attribute to a WordPress menu item
- Order posts (across the whole site) by metadata date
- Relative URLs and hide /wp-content/themes/
- Disable visual editor on one specific page
- Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php?
- Removing Unnecessary Text from Admin Menu without CSS
- Display WordPress Search
- Remove_filter (‘the_content’, ‘wpautop’) is not working
- Multisite, either change the name of sample-page or create new page
- What is the “icon” parameter in wp_get_attachment_image_src used for?
- How to use thumbnails in gallery?
- Hide Author.php template from specific user role
- Customizer field value into functions.php variable
- How can I load a javascript file that is type=”module” the WordPress way?
- How to manage arrays from custom functions stored in functions.php?
- list tags with count in author profile page
- Running a script before absolutely everything
- Auto delete post if certain custom field data is empty
- using `require` in my functions.php breaks the site
- Is it OK to include files using ABSPATH?
- How to fetch the name of the active menu?
- Function shortcode – Set Parameter
- Is there a way to prevent a function/method from being called outside a specific hook?
- attachment page template? only show attachments for current post?
- Nav menus all outputting the same links
- Secondary Menu and Logged In Users
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- Adding code before post title with the_title produces weird results
- Remove the month and year from a WordPress Date?
- How to insert class in each list of categories?
- Add Link to Users List (Backend) to open each users front-end profile
- Editing the formatting.php file vs functions.php file?
- Function not saving unchecked checkbox
- Removing parent theme CSS without editing parent theme
- Entirely Different Functions.php per Page?
- Hide Author By-Line if After Certain Date
- wp_title() return random number
- How to offset main query without affecting other queries and backend
- ACF Date Form in Custom Admin Field
- How to pass data from a plugin to functions.php
- Function to disable “href” anchor tags that contain “a data-name” on mobile only
- Execute jQuery with custom event listener after successfully add an item to the cart
- WordPress hooks to call a function inside a construct
- WordPress undefined function error on using add_action() in functions.php
- how to display featured image for single post for a specific category
- Load a Child Theme’s style.css just before the closing tag
- Can’t wrap my head around this function – any help would be appreciated
- Figure inlined width trigger distorted layout
- save_post hook – headers already sent?
- Exclude javascript in certain page url and all following url’s after forward slash
- How to test for a class (from a plugin) in functions.php
- Child Theme not working – CSS gone
- Custom shortcode not being included in content paragraph [duplicate]
- Display post_meta-by_key on product catalogue
- Which template file to edit to edit homepage in Mystile [closed]
- comment_post function with js not running