Use this function instead. Then put the_excerpt(); in your template.
/**
* Find the last period in the excerpt and remove everything after it.
* If no period is found, just return the entire excerpt.
*
* @param string $excerpt The post excerpt.
*/
function end_with_sentence( $excerpt ) {
if ( ( $pos = mb_strrpos( $excerpt, '.' ) ) !== false ) {
$excerpt = substr( $excerpt, 0, $pos + 1 );
}
return $excerpt;
}
add_filter( 'the_excerpt', 'end_with_sentence' );
Related Posts:
- Get excerpt from $post->post_content
- How to use the_excerpt in a filter hook?
- add_filter on “the_excerpt” only works when post does not have excerpt
- get_the_excerpt() with fallback like the_excerpt()
- How do I filter get_the_excerpt() but keep all of its functionality intact?
- Buddypress: Edit activity when new blog post [closed]
- Why in archive page doesn´t show read more button with excerpt?
- the_excerpt filter with an empty excerpt
- Access get_the_title() from ‘excerpt_length’ filter
- Give “Read More” precedence over excerpt() word count
- How do I override the_excerpt so that it will display full content?
- the_excerpt filter doesn’t work as expected
- Excerpt is being added above the content, but it should be after it
- run shortcode in excerpt of single custom post type
- apply_filters(‘get_the_content’, $content) + Except
- Trimming a custom field to a length
- Adding html banner to posts
- Apply wordpress filter checking category
- Add Filter – Pass Variable (PHP < 5.3)
- Filter Post Title without affecting screen-reader-text
- Create different flavours of excerpt
- Cutting off excerpt with first sentence
- Auto-generated excerpt with shortcode and read more button/text link
- Read More in the actual excerpt
- is_page_template() doesn’t work with excerpt_length filter
- the_excerpt() does not work with has_excerpt()?
- get_the_excerpt on mobile still displays continue reading
- Custom excerpt_more filter not working when tag is present
- Why does using excerpt_more filter change link location?
- Remove classes from body_class
- wp_headers vs send_headers. When to use each?
- Filter any HTTP request URI?
- Is it possible to filter comments in a post so a user can only see the comments they have written?
- Where to hook into post content?
- What hook do I use to edit the post statuses option in admin?
- Check if a filter or function has been already been called
- Filter Widget Title Wrap
- Customizing WordPress the_title with add_filter
- How can I send data to admin-ajax via JS Fetch?
- Disable resizing of gif when uploaded
- How to change Woocommerce breadcrumbs content?
- I’m using a filter to remove the tags auto wrap, but there still wrapped elements?
- How to enable visual editor when editing comments on the dashboard?
- Add ‘if exists’ to filter
- How to get current action?
- How to check if “media_send_to_editor” is audio?
- Changing Order of Filters
- Please help me through this example with a filter to understand how they work
- how to change appearence of the content of default post list columns?
- Filter custom post types in archive
- Use safety filters even if after applied intval?
- How can I filter block registration based on post-type? (Block alignment settings)
- wp_insert_post_data filter not working correctly after upgrade to WordPress 5
- Modify site URL via functions.php of a theme
- Yoast SEO hooks overriding themselves
- Passing variable from child theme to parent theme
- Question about how do wordpress filters/actions work
- How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?
- How to take options from form fields and turn them in to links?
- How add a group by to the query used by the media library?
- How to properly modify WP Vary or any existing headers?
- Filters on Login Page
- How to filter link?
- Conditional does not work with add_filter
- How can I apply filters in my class that extends Walker_Nav_Menu?
- Pass debug_backtrace() in WordPress filter
- How to edit embed filter for youtube video to allow responsive full width layout
- Remove get_template_part() from custom theme
- How to access page variable inside action hook
- Shorten the title length
- Problem with Class, Filters and Callbacks
- Renaming wordpress login and get new password button
- preg_match() not working with post content
- Search a title word through query_posts (not the exact match)
- Parse a shortcode differently based on on what it’s nested in
- Elementor Image Hover + Filter Grid [closed]
- How to redirect template_directory to subdomain relativ url?
- comment_notification_text filter not working
- Line Breaks are stripped off when direction property is found
- Scanning for custom embed and prefetching
- WordPress remove_filter not working
- How to exclude or include categories in wp rest API without query parameters?
- Remove and replace woocommerce add to cart button [closed]
- Replace a specific URL on all apperances on the Website (Maybe a filter?)
- Modify Contextual Help
- how to use apply filter for Class?
- Modify WordPress search behaviour in backend?
- Re-order search results with posts_orderby filter and post meta value
- ‘the_content’ Filter delivers empty string with lengh (608)
- Testing requested query in pre_get_posts
- Output dynamic_sidebar_params in wp_head
- How to sort posts according to meta value?
- I can get the permalink or the excerpt to work correctly, but not both
- Modify WooCommerce email shipping text value
- Using Filters To Change Page Title
- remove_filter excerpt_more from a plugin class
- How to elect position of new item output in a dropdown when using add_filter
- Query Multiple Filters, one with Meta
- Filter a custom post type by custom field in admin
- How to change content hash value, within the_block_template_skip_link action?