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?
- How to show page content in feed?
- apply_filters() and the_excerpt are giving unexpected results
- remove_filter( ‘the_content’, ‘wpautop’ ); only for certain post types
- Valid characters for actions, hooks and filters
- How do I filter the excerpt metabox description in admin?
- AJAX filter posts on click based on category
- Can I add custom meta for each image uploaded via media-upload.php?
- How do I know if author field was changed on post save?
- Load different template file when condition met?
- Format content value from DB outside of WordPress filters
- Can’t change the title tag with wp_title filter
- How to filter ‘post_gallery’ after all other filters/plugins etc
- Cron schedule interval through plugin options?
- wpmu_signup_user_notification filter not working
- Filter oembeds tags to modify iframe attributes
- Removing labels and tag on WordPress’s default login form
- How to check a filter are applied
- Add $more_link_text parameter to the_excerpt()
- How do I add a listbox to the TinyMCE editor?
- How to remove google font in WordPress for only single page?
- Why anything done on comments_array hook gets reset?
- Is there a get_post(s) filter that can alter/replace the output completely?
- add filter login_redirect does not contain original requested redirect
- get_header and hook avoid normal call
- Dropdown filter in custom posts
- Modify WP_Post before processing
- How to order by taxonomy using wp_query
- Filter taxonomy admin pagination
- Feed, RSS not able to clear the cache and cannot change the limit of cache life time
- WP action/filter to modify title before header output and article output?
- Custom view counts not updating correctly
- To add a custom filter based on a meta field
- How to create Woocommerce Product Filter Widget [closed]
- Add default user field to WooCommerce checkout [closed]
- Filtering Comment Reply Links (comment_reply_link_args) for “infinite replies” in nested comments
- Create Search Form to Filter Through Terms
- Formatting get_post content doesn’t allow JS content to function properly
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- How can I change the email that is inside the default email texts of wordpress?
- How to filter link?
- Conditional does not work with add_filter
- Modify message displayed on post save
- Pass debug_backtrace() in WordPress filter
- I need to hook and change language of facebook sdk
- change “missing attachment” text functions.php
- Use has_filter on comment_post
- Shorten the title length
- Problem with Class, Filters and Callbacks
- Renaming wordpress login and get new password button
- 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?
- How do I add tags to entire comments, not just their text
- add_filter( ‘the_title’ gets through this if statement twice
- Changing the category for existing Gutenberg blocks
- Modify WordPress Page Title ()
- How to add lazy field in content endpoint using Gutenberg blocks
- how to use apply filter for Class?
- How can I see exactly what arguments are being passed through a filter so that I may modify them?
- Re-order search results with posts_orderby filter and post meta value
- Set Microsoft Word links to open in new window/tab
- WordPress get_avatar filter to match logins
- ‘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?
- Change shortcode output (filter?)
- How do I add a class to all sidebars to let a Google Custom Search Engine know not to index the content?
- Updating User Profile on Registration
- remove_filter excerpt_more from a plugin class