You are viewing an old revision of this post, from March 17, 2014 @ 12:55:24. See below for differences between this version and the current revision.

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:24Current 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]&lt;?php wp_trim_words( $text, $num_words = 55, $more = null ); ?&gt;[/php]Unchanged: [php]&lt;?php wp_trim_words( $text, $num_words = 55, $more = null ); ?&gt;[/php]
 Added: &nbsp;
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.

Tags: ,

No comments yet.

Leave a Reply