denplaza
Member
Posted 7 months ago #
1. I type the text "...." in a post.
2. The HTML tab of the editor also shows "...."
3. The function the_content() returns the html code #8230; as text. (I removed the ampersand here.) The first three dots have been 'corrected' internally.
I always thought that the HTML tab of the WordPress editor was the same as what the the_content() function returned.
Character #8230 is a horizontal ellipsis but I just want the normal three dots. I'd like to ask, is there a way to prevent this without writing PHP script to alter the output of the_content()? I mean, can this be helped with a setting or another simple change?
Hi,
I think your issue might be caused by the wptexturize function. You can remove it from your theme by pasting this code into your functions.php file:
remove_filter('the_content', 'wptexturize');
Cheers!
denplaza
Member
Posted 7 months ago #
Thanks for pointing out wptexturize. I think it's a handy feature so I wouldn't want to switch it off entirely for a few occasions.
Unless someone has a more elegant solution (no offense to your option Marventus), here is what I will do. I'll remove the ellipsis from the core code. Then, when I have more time, I'll restore the core file and write some kind of 'reverse' filter that includes my exceptions... or something. Have to think a little more about it.
Any other suggestions, thoughts, etc?
denplaza
Member
Posted 7 months ago #
By the way, funny to see that the three dots in my previous post were not converted to the horizontal ellipis :) does this forum also ommit or adjust the wptexturize option? Moderators?
In that case, you will need to create a filter in your functions.php file:
function user_content_replace($content) {
return str_replace('#8230;','...',$content);
}
add_filter('the_content','user_content_replace', 99);
That should do it.
P.S.: Remember to add the ampearsand to the character.
denplaza
Member
Posted 7 months ago #
Thanks for that example Marventus.
You are welcome.
If you need to replace more than 1 character, str_replace accepts multiple needles and replacements as arrays.
Cheers!