Now this is not exactly a complex snippet of code, but something which I find use for on almost every project I work on.

Ever had the need to show a custom length of text as an excerpt, with no HTML markup?

This small but handy snippet of code makes it really quick and easy. Here is an example of bit being used inside a wp_query loop.

Remember this strips all HTML from the original text, so embed between <p></p> tags


Code Example

This function requires 3 inputs (2 are required and the suffix is optional).
  • $text(str) - This is your original text value, usually get_the_content or similar
  • $length(int) - Number of characters you wish to show
  • $suffix(str) - This follows any cut text, by default show more 

Post comment