Actually, I just did something like this for a Drupal site. I based my truncation function on this: Truncate text preserving HTML tags with PHP
Use the final version of the function at the end of the comments. The function takes its $length
parameter in characters, not words, but you can probably use the general rule-of-thumb of 5 characters per word to estimate, if needed.
Hook your function to the get_the_excerpt
filter, and you should be in pretty good shape.
Related Posts:
- Twenty Eleven home page show only excerpt
- How to programmatically bring back “excerpts” field in post editor in WP 3.1+
- How to hide and content from auto-generated excerpts?
- the_excerpt() not showing manual excerpt for Pages
- Bold letters inside excerpt [closed]
- How to move the the_excerpt’s read more link to another div
- buddypress: how do i make the group description excerpt shorter?
- the_excerpt(); tag not working
- Disabling automatic teasers
- How to make the excerpt_more filter apply to the actual post excerpt?
- How to obtain a reference to the_excerpt() from custom loop
- Exclude read more in the_excerpt [closed]
- Custom get_the_excerpt() only works on first post
- excerpt() shows different result between remote and localhost(development environment)
- adding class to excerpt
- Get Post’s Excerpt Without the Wrapping tags and the Read More link
- Single.php the_excerpt loads same as the_content not loading read more line
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- matisse theme show excerpts not whole content
- restrain filter on get_the_excerpt to queried item in stead of current post
- How to make force_balance_tags balance comment tag
- Filter URL and shortcodes from the_excerpt
- WordPress API Menu/Submenu Order
- What is the difference between wp_register_sidebar_widget and register_widget?
- How to enqueue script if widget is displayed on page?
- Form Submitting Error with get_template_part()
- Get 10 posts from a WP_Query. If less than 10, get the remainder from elsewhere
- Can’t get staging site to display same way as live site. Completely stumped
- How Do I Programmatically Force Custom Permalinks with My Theme?
- Is it feasible to build and update a WordPress website offline?
- Where is default wp_head() implemented?
- How do I hide tags that have only been used once?
- Questions about WordPress.org theme review
- Translated strings not appearing – what am I missing?
- Feature Survey – What would you want in a resume theme?
- Can I upload WordPress-react theme in Wp theme repository
- Select front page and blog page in custom theme settings page
- What are the Theme tags in style.css used for?
- WordPress nav_menu_css_class theme filter is not being called
- How do I locally enqeue the mediaelement.js file into a wordpress theme
- Cannot get full thumbnail size using the_post_thumbnail
- Version control for both Vagrant config and themes being developed [closed]
- wp_editor() usage in custom meta box
- Is there an action for save_menu and/or update_menu?
- Does a premium / for sale theme need to go through the WordPress approval process?
- filter out “uncategorized” from all category listings with one filter in functions.php?
- Is it possible to use Twitter intents with the post’s image in WordPress?
- How to add a user defined hyperlink to the “Featured Image” and the_post_thumbnail()
- Using PIE CSS in WordPress. “localizing” styles
- Category specific themes?
- Change locale by detecting viewer’s browser language setting and let them choose prefered language after
- Why is it needed to enqueue parent stylesheet in child theme?
- WordPress Unite Theme: Footer isn’t sticking [closed]
- How to set a correct $content_width when there are two content widths on one page?
- Limit number of users a role can create
- Do not display post images on front page
- Customize how a WordPress theme looks like in the Theme Selector
- Change WordPress header color using customizer
- Default Text not showing from customizer
- Images not showing after path specified in header.php
- How to set wp_options in functions.php for removeing the Default Front Page
- Template for landing pages
- How to Manually Code Shortcode?
- How to show a manageable list of images on a post?
- Where does the uploaded image go?
- Remove link on full-size images
- How to reset post data properly
- Theme options save routine clashes with plugin save
- get_search_query() not working with search queries with ampersand in it
- If user is logged in and has a role echo statement
- Fixed button and slideshow in template upload per page
- Let user to add input fields on theme option page
- Non-standard (new) theme file
- Best Practice for Server Processing
- MapPress Easy Google Map in Jquery Tabs Problem
- Homepage slider not using correct images
- WordPress Show Single Post on Home Page with previous/ Next Button
- Is there any way to store single.php wordpress file into a php variable
- How to change listing type permlink?
- Fatal error: Class WP_Customize_Image_Control not found
- Menu is in Reversed order
- Which theme PHP file should be edited in order to change Posts appearance
- Group several custom global page templates in sub-folder
- How to hide blog by id wordpress multisite listing
- Should I detect the device or the page first?
- Get chronological page order
- Query wp_postmeta into an array based on post_id
- Theme not uploading showing maximum upload size on live site
- How to override wordpress native options with theme options
- Best way to access variables in template markup
- How do I get my theme scripts to load in a custom theme built from Bootstrap
- Problem with multiple menus in theme
- How to convert that page to a wordpress template? [closed]
- Saving Permalinks Results in 403 MAMP (Windows)
- Add rel to all images in a post
- WordPress theme Modifications not showing up on live server
- Incorrect sidebar showing on WooCommerce Store page [closed]
- Which function(s) to build a paged HTML table
- white spaces on the all sides [closed]
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?