Opened 16 years ago
Closed 11 years ago
#8214 closed enhancement (fixed)
get_terms should support term descriptions
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description
Right now you can't use get_terms
to get terms based on description. I think it should treat description just like name, so I added a description__like
argument that works just like the name__like
argument. In my case, I wanted only terms that had a description, so I called it like this:
$args = array('description__like' => '_'); get_terms('post_tag', $args);
Attachments (5)
Change History (14)
#1
follow-up:
↓ 2
@
16 years ago
Wouldn't it be more useful if the searched-for term could be matched anywhere in the description? The way you have it, whatever description__like
is set to would have to appear at the beginning of the description.
Maybe call it instead search__description
have it be like this:
$where .= " AND tt.description LIKE '%{$search__description}%'";
#2
in reply to:
↑ 1
@
16 years ago
Replying to filosofo:
Wouldn't it be more useful if the searched-for term could be matched anywhere in the description? The way you have it, whatever
description__like
is set to would have to appear at the beginning of the description.
it does. from a performance standpoint, though, if this gets heavily used and an index is used on the description field, it won't be used in the query unless it's anchored to the beginning of the string.
#4
@
16 years ago
- Milestone changed from 2.8 to Future Release
Punting due to time constraints. Will reconsider in future dev cycle.
#6
@
14 years ago
- Cc aaroncampbell added
- Keywords has-patch 2nd-opinion added; needs-patch removed
I just refreshed the patch. It still matches only the beginning of the description just like name__like
only matches the beginning of the name. I know it's somewhat limiting but performance-wise it seems better. Maybe we should also consider adding tt.description to the search? Something like:
if ( !empty($search) ) { $search = like_escape($search); $where .= " AND (t.name LIKE '%$search%' OR tt.description LIKE '%$search%')"; }
Adds descriptionlike arg to get_terms