Error in excerpt length calculation when using “more”
-
You are calculating the length of the string down to where the “more” comment block appears in the content, but further functions are applied (strip_shortcodes, strip_tag, stripslashes) to that string which may reduce its size, causing the length calculation to be incorrect.
It’s also worth pointing out that this function is flawed in another crucial way: if you don’t remove all HTML tags for excerpts automatically generated from the post content, you may end up in a situation where HTML tags are truncated or incomplete, which can (and has) break a website’s layout. One solution for this would be to strip all tags from automatically generated excerpts, but allow them when using the more block for example. I ended up overriding this entire function.
- The topic ‘Error in excerpt length calculation when using “more”’ is closed to new replies.