Opened 11 years ago
Last modified 6 weeks ago
#32824 new enhancement
Consistent search fields between posts and terms
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Posts, Post Types | Keywords: | good-first-bug has-patch has-unit-tests |
| Focuses: | administration | Cc: |
Description
Searching for posts currently checks the post_title and post_content fields, while searching terms checks the name and slug fields. Could post_name be added to the where clause for posts, and description be added to terms? That way, searching would consistently check an entity's title, slug, and content.
Attachments (2)
Change History (9)
#1
@
11 years ago
- Component changed from General to Posts, Post Types
- Type changed from defect (bug) to feature request
#3
follow-up:
↓ 5
@
9 years ago
- Keywords needs-patch added; dev-feedback removed
Makes sense, but some performance impact numbers will be needed to ensure search queries don't get slowed down any more than they already are.
#5
in reply to:
↑ 3
@
6 months ago
- Focuses administration added
- Keywords has-test-info good-first-bug added
- Milestone changed from Awaiting Review to Future Release
- Type changed from feature request to enhancement
Replying to johnbillion:
Makes sense, but some performance impact numbers will be needed to ensure search queries don't get slowed down any more than they already are.
Without search restriction parameters in the UI, performance impact is going to be always there and not much we should do about it, considering that currently search for posts is being done in Content, which is, by far the worse of all in terms of performance, not any close (more with the current content GB formats)
Personally I believe that search by post_name can be a little overkill and searching by Term description, I'm no going to say that is the most demanded feature, but its fair and gives consistency. (Also searching by slug in terms was an overkill also, clearly a poor design feature that was decided on the fly for the sake of adding it)
Do we want to provide consistency for all 3, title/slug/content? Then both should be added.
For testing is pretty simple: Just add a random word to slug in posts or description in terms, and search for it.
#6
@
2 months ago
- Keywords has-patch needs-testing has-unit-tests added; needs-patch has-test-info removed
This patch: https://core.trac.wordpress.org/attachment/ticket/32824/32824.post-slug-and-term-description-not-considered-for-search.patch addresses incomplete search behavior in both post and term queries.
Updated the following files:
- src/wp-includes/class-wp-query.php:1455
- src/wp-includes/class-wp-term-query.php:1110
For posts, admin search results were not matching against the post slug
(post_name). The patch includes post_name in the default search columns
used by WP_Query.
For terms, searches did not match keywords present only in the term
description. The patch updates the term search SQL to include the term
taxonomy description.
New PHPUnit tests are included to cover both cases and ensure correct
behavior when the search term exists only in the slug or description.
Tests pass locally.
The following test files are updated:
- tests/phpunit/tests/query/search.php
method added: test_search_matches_post_slug
- tests/phpunit/tests/term/query.php
method added: test_search_matches_term_description
#7
@
6 weeks ago
- Keywords needs-testing removed
Patch Testing Report
Patch Tested:
https://core.trac.wordpress.org/attachment/ticket/32824/32824.post-slug-and-term-description-not-considered-for-search.patch
Environment
- WordPress: 7.0-alpha-61215-src
- PHP: 8.2.29
- Server: nginx/1.29.4
- Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
- Browser: Chrome 143.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Two 2.1
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.1
Steps taken
Post search (post slug)
- Created a new post with:
- Title: Improving Admin Search Consistency
- Content: This post discusses how search behavior in the WordPress admin can be made more consistent across different object types.
- Slug: admin-search-consistency-enhancement
- Navigated to Posts → All Posts.
- Searched for "admin-search-consistency-enhancement".
Category search (term description)
- Created a new category with:
- Name: Admin Experience
- Slug: admin-experience
- Description: This category contains posts related to improvements in the WordPress administration interface, including search usability, content management workflows, and overall editorial experience.
- Navigated to Posts → Categories.
- Searched for "editorial experience".
- Repeated the above steps before and after applying the patch.
- ✅ Patch is solving the problem
Expected result
- Post admin search returns results when the search term exists in the post title, slug (post_name), or content.
- Category admin search returns results when the search term exists in the term name, slug, or description.
- Search behavior is consistent across posts and terms by checking title/name, slug, and descriptive content.
Screenshots/Screencast with results
- Screencast showing results before and after applying the patch: https://files.catbox.moe/r6um53.mp4
I'd be interested in @johnbillion's take on adding these extra searchable fields by default.