Make WordPress Core

Opened 6 years ago

Last modified 4 years ago

#44969 new enhancement

Add support to limit results in get_objects_in_term()

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: 2nd-opinion has-patch has-unit-tests
Focuses: Cc:

Description

The get_objects_in_term() function currently returns all object IDs related to a term in a taxonomy. On sites with many term relationships, this may result in tens of thousands of them.

Without a way to limit the results, developers currently need to write their own custom database query just to inject their own LIMIT clause.

Conveniently, the get_objects_in_term() function already has a third $args parameter that's currently only used to pass in a sort-order of ASC or DESC, so adding support for other query clauses is technically straight forward.

Attachments (1)

44969.patch (3.5 KB) - added by mauteri 4 years ago.
Patch to add limit feature to $args for get_objects_in_term; unit tests included.

Download all attachments as: .zip

Change History (2)

@mauteri
4 years ago

Patch to add limit feature to $args for get_objects_in_term; unit tests included.

#1 @mauteri
4 years ago

  • Keywords has-patch has-unit-tests added

Happened to be wondering the same thing while working with this function and saw this open ticket :-D

Note: See TracTickets for help on using tickets.