Today, I discovered that WordPress 3.3 actually has a similar core function called wp_trim_words().
The function works like so:
[php]<?php wp_trim_words( $text, $num_words = 55, $more = null ); ?>[/php]
[php] php echo wp_trim_words( get_the_content(), 100, '...' );[/php]Revisions
- March 17, 2014 @ 12:55:46 [Current Revision] by PeterLugg
- March 17, 2014 @ 12:55:46 by PeterLugg
- March 17, 2014 @ 12:55:24 by PeterLugg
Revision Differences
| March 17, 2014 @ 12:55:24 | Current Revision |
| Title |
| Deleted: | Added: Trim Your Text with wp_trim_words() in WordPress |
| Content |
| Unchanged: Today, I discovered that WordPress 3.3 actually has a similar core function called wp_trim_words(). | Unchanged: Today, I discovered that WordPress 3.3 actually has a similar core function called wp_trim_words(). |
| Unchanged: The function works like so: | Unchanged: The function works like so: |
| Unchanged: [php]<?php wp_trim_words( $text, $num_words = 55, $more = null ); ?>[/php] | Unchanged: [php]<?php wp_trim_words( $text, $num_words = 55, $more = null ); ?>[/php] |
| | Added: |
| Unchanged: [php] php echo wp_trim_words( get_the_content(), 100, '...' );[/php] | Unchanged: [php] php echo wp_trim_words( get_the_content(), 100, '...' );[/php] |
Note: Spaces may be added to comparison text to allow better line wrapping.
No comments yet.