Opened 13 years ago
Closed 10 years ago
#19904 closed enhancement (fixed)
Trim Leading and Trailing White Space in a Post Title
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 4.1 | Priority: | normal |
Severity: | normal | Version: | 3.3.1 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | Cc: |
Description
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
trim($post_title);
Attachments (2)
Change History (9)
#3
@
13 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' );
#4
@
11 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
#5
@
10 years ago
- Keywords has-patch added; needs-patch removed
The attached patch works as expected, removing any whitespace at the beginning and end of post titles.
The trim of this should be on save. That way it goes into the db correctly without the spaces.