Make WordPress Core

Opened 6 years ago

Last modified 4 years ago

#45084 new enhancement

WP_Term_Query multiple 'orderby' support

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

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 6 years ago.
Patch to support multiple orderby clauses for terms.
45084.2.patch (1.8 KB) - added by keraweb 6 years ago.
Enhanced patch to support multiple orderby clauses for terms.

Download all attachments as: .zip

Change History (8)

@keraweb
6 years ago

Patch to support multiple orderby clauses for terms.

#1 @keraweb
6 years 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
6 years ago

Enhanced patch to support multiple orderby clauses for terms.

#2 @pento
6 years ago

  • Version trunk deleted

#3 @desrosj
6 years 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 years 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 years 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.

#6 @coreyw
4 years ago

This would be awesome to have. WordPress could just have an "Order" field built in like they do for pages, and could order terms by "order asc" and "name asc" by default.

Note: See TracTickets for help on using tickets.