Why is wordpress suddenly stripping away all newline characters and how to disable this?
-
20-04-2021 - |
Вопрос
I've spent about 3 hours trying out various functions to figure out why the newline characters are being removed every time I save.
How do I figure out why is wordpress suddenly stripping away newline characters? I have not installed any plugins. How can I get newline characters to show up on my site without converting all blocks to HTML and modifying everything in code?
Решение
I found the following snippet which we can add to functions.php . I'm adding these via a plugin.
function clear_br($content) {
return str_replace("<br>","<br clear='none'>", $content);
}
add_filter('the_content','clear_br');
Note that I've put "<br>"
tag which is what wordpress creates when you enter newline characters.
Не связан с wordpress.stackexchange