Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#19904 new feature request

Trim Leading and Trailing White Space in a Post Title

Reported by: greenspeakmedia Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.3.1
Component: General Keywords:
Focuses: Cc:


In working with clients today I realized that they were copying and pasting post titles but including a leading space in it by accident. Because of this the orderby feature of the query wasn't appearing to work. Turns out it was but the spaces where all correct so it was messing with the query.

I think it would make sense that on a title field of a post/ page that any leading whitespaces and any trailing white spaces should be trimmed off.

something like


Change History (3)

comment:1 greenspeakmedia2 years ago

The trim of this should be on save. That way it goes into the db correctly without the spaces.

comment:2 jane2 years ago

Yes, please.

comment:3 nacin2 years ago

We already do this on display, so one of the few places you would indeed see this is ordering.

This would handle it: add_filter( 'trim', 'title_save_pre' );

Note: See TracTickets for help on using tickets.