Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

Quick guess would be:

add_filter('content_save_pre', 'trim');

Add to functions.php of theme or wherever is appropriate in your site.

share|improve this answer
    
Doesn't work. Maybe it's because the post is still full of trailing  s ? –  a paid nerd Aug 30 '11 at 4:16
    
@a paid nerd likely that. trim() only removes true whitespace. It worked for me in quick test, but I used HTML editor. Likely your writer is using visual one that encodes spaces. You will need to hook your own function that will delete (or convert to regular spaces before trim) those entities. –  Rarst Aug 30 '11 at 8:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.