Opened 15 years ago
Closed 10 years ago
#14156 closed enhancement (wontfix)
Option to use name, in additon to slug and id in get_term_link() function
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | normal | Version: | 3.0 |
Component: | Taxonomy | Keywords: | 2nd-opinion |
Focuses: | Cc: |
Description
Right now the get_term_link() function (in wp-includes/taxonomy.php) can be used only with either term id or term slug.
It would be useful to provide an option to add name in addition to term id and slug.
This function inturn uses get_term_by() function and it has the option to provide term name, but the get_term_link() function doesn't have a way to do this.
Attachments (3)
Change History (22)
#2
@
15 years ago
- Milestone changed from Awaiting Review to 3.1
- Priority changed from normal to low
+1 on the idea.
#3
@
15 years ago
On the other hand, while I agree that:
get_term_link( 'Term Name', 'taxname', 'name' )
looks better than:
get_term_link( get_term_by( 'name', 'Term Name', 'taxname' ), 'taxname' )
, it's just an implementation detail. get_term_link() shouldn't be concerned with retrieving the correct term.
To avoid passing the taxonomy over and over again, it would be nice if you could do something like this instead:
get_term_by( 'name', 'Term Name', 'taxname' )->get_link()
#9
@
10 years ago
- Keywords needs-refresh needs-unit-tests removed
14156.patch refreshes the patch.
14156-tests.patch adds unit tests.
#11
@
10 years ago
- Owner set to boonebgorges
- Resolution set to fixed
- Status changed from new to closed
In 32553:
#13
follow-up:
↓ 14
@
10 years ago
- Keywords 2nd-opinion added; has-patch removed
- Resolution fixed deleted
- Status changed from closed to reopened
I'm a little concerned that this introduces yet more inconsistency with regard to which term functions accept which values for their $term
argument. This is now the only term function apart from get_term_by()
which accepts a $field
argument.
Should we add the $field
parameter to get_term_feed_link()
, get_edit_term_link()
or other term functions too?
#14
in reply to:
↑ 13
@
10 years ago
Replying to johnbillion:
Should we add the
$field
parameter toget_term_feed_link()
,get_edit_term_link()
or other term functions too?
I can send a new patch for this with $field
parameter for both the functions if we decided to do it.
This ticket was mentioned in Slack in #core by helen. View the logs.
10 years ago
#16
@
10 years ago
I'm leaning toward reverting this - I'm not completely sure in what scenario you only have the term name available to you, and doing a get_term_by()
first yourself is more correct than mixing this into get_term_link()
IMO. I'd way rather get on a WP_Term
object, see #14162 for that.
Path which adds the third parameter to get_term_link function