Make WordPress Core

Opened 11 years ago

Closed 9 years ago

#4889 closed enhancement (invalid)

Extend get_terms to add custom joins / wheres

Reported by: arnee Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:


Example: I want to get all categories which actually have posts.

  • Old way: SELECT... FROM wp_cats... JOIN wp_posts... WHERE post_status='publish'
  • New way: get_terms("category")

The problem is that I can't specify any properties of the related object so I would have to use direct SQL again instead of a clean API function.

Solution: Extend get_terms to add properties of the related object. get_terms should know which table needs to be joined via the object_type property.

Change History (5)

#1 @foolswisdom
11 years ago

  • Milestone changed from 2.3 to 2.4 (next)

#2 @ffemtcj
10 years ago

  • Milestone changed from 2.5 to 2.7

No Patch. Moved to 2.7

#3 @ryan
10 years ago

  • Milestone changed from 2.7 to 2.8

9 years ago

  • Milestone changed from 2.8 to Future Release

#5 @Denis-de-Bernardy
9 years ago

  • Component changed from General to Taxonomy
  • Milestone Future Release deleted
  • Resolution set to invalid
  • Status changed from new to closed

use a WP_Query object, override the fields, and toss in joins and a group by.

Note: See TracTickets for help on using tickets.