WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 8 months ago

#14156 new enhancement

Option to use name, in additon to slug and id in get_term_link() function

Reported by: sudar Owned by:
Milestone: Future Release Priority: low
Severity: normal Version: 3.0
Component: Taxonomy Keywords: has-patch needs-refresh
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 (1)

get_term_link.patch (721 bytes) - added by sudar 4 years ago.
Path which adds the third parameter to get_term_link function

Download all attachments as: .zip

Change History (8)

sudar4 years ago

Path which adds the third parameter to get_term_link function

comment:1 sudar4 years ago

  • Keywords has-patch added

comment:2 scribu4 years ago

  • Milestone changed from Awaiting Review to 3.1
  • Priority changed from normal to low

+1 on the idea.

comment:3 scribu4 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()

comment:4 scribu4 years ago

Related: #14162.

comment:5 scribu4 years ago

Related: #13081.

comment:6 markjaquith3 years ago

  • Milestone changed from 3.1 to Future Release

To late for enhancements for 3.1.

comment:7 wonderboymusic8 months ago

  • Keywords needs-refresh added; taxonomy get_term_link removed
Note: See TracTickets for help on using tickets.