Opened 13 years ago
Last modified 6 years ago
#20044 new enhancement
Enable search for pages by slug
Reported by: | ekitomat | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.7 |
Component: | Query | Keywords: | needs-testing needs-patch |
Focuses: | Cc: |
Description
Would be nice to be able to search a page by its slug. Might need to be a bit different depending on the permalink-strategy.
Steps to reproduce(with Post name-permalinks enabled):
- Create a new page with a specific slug
- Save page
- Search for the exact slug-name
Attachments (5)
Change History (21)
#2
@
12 years ago
- Keywords has-patch needs-testing added; needs-patch removed
20044.diff uses the page_name
column with LIKE
, just like the post title and content. Needs testing, preferably on a large dataset with query caching disabled, not entirely sure how this will hit performance.
#4
@
11 years ago
- Milestone changed from 3.7 to Future Release
#7394 necessitates this doesn't move forward yet.
#5
@
11 years ago
- Keywords needs-testing removed
- Milestone changed from Future Release to 3.9
- Version set to 3.7
20044.2.diff refreshes and adds Unit Tests.
#6
@
11 years ago
20044.3.diff implements this as a filter on query_search_fields
, which is more flexible than just jamming post_name
in there. Because at that point, why not also add post_excerpt
? This puts the onus on the developer to make the right decision in regards to performance.
Added query/search.php
to unit tests.
#8
@
11 years ago
I'd also like to see the filter simply be for post fields, so 'post_content', 'post_title', etc., rather than having an explicit table reference inside the filter.
#9
follow-up:
↓ 10
@
11 years ago
- Keywords needs-docs removed
20044.4.diff checks anything passed in the filter against an array of allowed search fields—post_title, post_content, post_name, and post_excerpt—and then sets up the query.
I left out other posts fields from the allowed list as they don't seem applicable. Docs added to the query_search_fields
filter as well.
#10
in reply to:
↑ 9
@
11 years ago
- Keywords needs-testing added
- Severity changed from trivial to normal
Replying to jeremyfelt:
20044.4.diff checks anything passed in the filter against an array of allowed search fields—post_title, post_content, post_name, and post_excerpt—and then sets up the query.
I left out other posts fields from the allowed list as they don't seem applicable.
Just to be clear, the filter in 20044.4.diff effectively expands the available search fields to also include post_excerpt
and post_name
*only*. Does it not limit the usefulness of the filter to say, "You can customize the search fields, but are limited to choosing within this list of four?".
Docs added to the
query_search_fields
filter as well.
Very nice :)
#12
@
11 years ago
I managed to not commit the original tests from #7394, which was to have added tests/query/search.php.
post_content_filtered should also be made available.
#13
@
11 years ago
- Keywords punt added
20044.5.diff cleans things up a bit.
That said, this doesn't help with ordering. In fact, #7394 kind of gets in the way here (it was fixed after this ticket was opened). You could add more fields to search, or even remove some, but it doesn't affect the ordering — a perfect post_name match ends up on the final page of results. That's not a great experience. Some earlier patches on #7394 allowed for the reverse: it helped with ordering but not with which fields were searched. Seems like we should add both tools at once.
Adds the
page_name
column to query's search