Problem with hidden chars
-
[ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]
Hi,
I’m using a template who strip the content to create excerpt, the problem is that once in a while (but getting more frequent now) it happens to find a hidden chars (not identified yet) which will prevent it from stripping the content and would give away an error like this:
Warning: Wrong parameter count for substr() in /../wp-content/themes/tk/functions.php on line 160
Which is:
$content = substr($content, 0, $espacio, "utf-8"); The whole function is: function wp_limit_post($max_char, $more_link_text = '[...]',$notagp = false, $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = strip_tags($content); if (strlen($_GET['p']) > 0) { if($notagp) { echo mb_substr($content,0,$max_char, "utf-8"); } else { echo '<p>'; echo mb_substr($content,0,$max_char, "utf-8"); echo "…</p>"; } } else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { $content = substr($content, 0, $espacio, "utf-8"); $content = $content; if($notagp) { echo mb_substr($content,0,$max_char, "utf-8"); echo $more_link_text; } else { echo '<p>'; echo mb_substr($content,0,$max_char, "utf-8"); echo $more_link_text; echo "…</p>"; } } else { if($notagp) { echo mb_substr($content,0,$max_char, "utf-8"); } else { echo '<p>'; echo mb_substr($content,0,$max_char, "utf-8"); echo "…</p>"; } } }
To repair this manually I have to delete one phrase after the another know where is the hidden chars, then when I find the phrase I have to delete it and rewrite it directly into WordPress, and it will work. This is quite a pain as this is happening almost once a week now.
Thanks for your help,
Rui
- The topic ‘Problem with hidden chars’ is closed to new replies.