WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 6 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:

Description

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)

comment:1 @foolswisdom8 years ago

  • Milestone changed from 2.3 to 2.4 (next)

comment:2 @ffemtcj7 years ago

  • Milestone changed from 2.5 to 2.7

No Patch. Moved to 2.7

comment:3 @ryan7 years ago

  • Milestone changed from 2.7 to 2.8

comment:4 @FFEMTcJ6 years ago

  • Milestone changed from 2.8 to Future Release

comment:5 @Denis-de-Bernardy6 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.