WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 9 months ago

#21651 closed enhancement (fixed)

Add term_taxonomy_id to available fields in get_term_by

Reported by: jchristopher Owned by: wonderboymusic
Milestone: 3.7 Priority: normal
Severity: minor Version: 3.4.1
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

In my experience term_taxonomy_id has proven to be exponentially useful in a number of ways, specifically in prevention of same-id collisions of terms used in multiple taxonomies. I'd love to be able to grab a term object by passing along its term_taxonomy_id to get_term_by(). A recent change was made to WP_Query that provides this functionality, so I'm hoping this makes the cut as well.

Attachments (3)

get_term_by-term_taxonomy_id.patch (113.4 KB) - added by jchristopher 3 years ago.
21651.diff (520 bytes) - added by wonderboymusic 2 years ago.
21651.2.diff (1.6 KB) - added by wonderboymusic 2 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 @sc0ttkclark3 years ago

  • Cc lol@… added
  • Keywords dev-feedback added

+1!!!

comment:2 in reply to: ↑ description @souri2 years ago

+1!!!

Version 0, edited 2 years ago by souri (next)

comment:3 @wonderboymusic2 years ago

  • Keywords dev-feedback removed
  • Milestone changed from Awaiting Review to 3.7

Patch still applies

@wonderboymusic2 years ago

@wonderboymusic2 years ago

comment:4 @wonderboymusic2 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 25334:

Add term_taxonomy_id to available fields in get_term_by(). Adds unit test.

Props jchristopher.
Fixes #21651.

comment:5 follow-up: @helen2 years ago

Shouldn't $taxonomy be optional if getting by term_taxonomy_id?

comment:6 @wonderboymusic2 years ago

cache group, filters, whatnot - the field's main advantage is primary key lookup

Last edited 2 years ago by wonderboymusic (previous) (diff)

comment:7 @wonderboymusic2 years ago

I guess you could get it from the term, would have to branch the SQL and all that noise.

comment:8 @helen2 years ago

Yeah, I know it's not a "oh hey just add = '' and done thing. Just seems of limited use otherwise.

comment:9 @ircbot12 months ago

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.

comment:10 in reply to: ↑ 5 @SergeyBiryukov9 months ago

Replying to helen:

Shouldn't $taxonomy be optional if getting by term_taxonomy_id?

Related: #30620

Note: See TracTickets for help on using tickets.