My writer has a tendency to add extra newlines (Enter key) and spaces (space bar) at the ends of posts. Sometimes this results in inches of extra whitespace onscreen!
Is there a way I can make sure extra trailing whitespace is removed when he hits “Update” in the WordPress post editor?
Quick guess would be:
Add to
functions.php
of theme or wherever is appropriate in your site.This will stop the trailing non-breaking spaces from displaying without actually modifying the post in the database when added to functions.php (or wherever your theme stores user added functions).
The ‘problem’ here is that wordpress converts ‘enters’ into paragraphs (< p >). Trailing and leading paragraphs result in large white spaces messing up your design. The wp (wysiwyg) editor is setup pretty spaciously and this often leads a user into believing the content is clean.
Check this very simple plugin, Space Remover, it removes these unintended paragraphs and gives you control over this functionality as well. (in case you want to use that extra space on some posts/pages)
If you want to remove not only one but several trailing non-breaking spaces, you could use a variation of UncaJoes code which also uses the default php rtrim charlist.