WordPress.org

Make WordPress Core

Opened 12 months ago

Last modified 5 months ago

#45084 new enhancement

WP_Term_Query multiple 'orderby' support

Reported by: keraweb Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Query Keywords: needs-unit-tests has-patch
Focuses: Cc:
PR Number:

Description

Just like in the regular WP_Query it would be awesome if it supported multiple orderby values (array or space separated).

I'm currently busy with a patch but the I would like some feedback and help with creating unit tests.

Examples:

<?php
get_terms(
   'orderby' => 'meta_value name',
   'order' => 'ASC',
);
<?php
get_terms(
   'orderby' => array(
      'meta_value' => 'ASC',
      'name'       => 'ASC',
   ),
);

Attachments (2)

45084.patch (2.1 KB) - added by keraweb 12 months ago.
Patch to support multiple orderby clauses for terms.
45084.2.patch (1.8 KB) - added by keraweb 12 months ago.
Enhanced patch to support multiple orderby clauses for terms.

Download all attachments as: .zip

Change History (7)

@keraweb
12 months ago

Patch to support multiple orderby clauses for terms.

#1 @keraweb
12 months ago

  • Keywords has-patch needs-docs added

I've added a patch to support this. The functionality works the same as with WP_Query (posts).

As for documentation, I'm not sure where to add this.

Same goes for unit tests, if anyone could help me with this that would be great!

@keraweb
12 months ago

Enhanced patch to support multiple orderby clauses for terms.

#2 @pento
9 months ago

  • Version trunk deleted

#3 @desrosj
6 months ago

  • Milestone changed from Awaiting Review to Future Release

Hi @keraweb,

Thanks for this! Are you able to work on adding unit tests? That would help push this along.

#4 @keraweb
6 months ago

Hi @desrosj,

No problem. And I'm not familiar with unit testing in WP core that much. I do use it for my own plugins though and I suppose the unit tests could be similar to the ones used for WP_Query itself (posts) right?
Could you point me to the right location? Also, how would I add a unit test as a patch?

#5 @desrosj
5 months ago

  • Keywords dev-feedback needs-codex needs-docs removed

@keraweb I recommend checking out these areas of the Core Contributor Handbook:

If you want to give it a try, I'm happy to provide some feedback for you to push this along.

Note: See TracTickets for help on using tickets.