Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#37545 closed defect (bug) (fixed)

`taxonomy` param of `WP_Term_Query` doesn't accept string value

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 4.6 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch commit dev-reviewed
Focuses: Cc:

Description

...even though it says it does.

See https://wordpress.org/support/topic/passing-a-single-taxonomy-as-a-string-to-wp-term-query-returns-error

I vaguely remember it being a conscious choice not to accept string values for taxonomy, but somehow it snuck into the documentation. In retrospect, I think it's fine (and consistent with other Query classes) to accept a string here.

Attachments (1)

37545.diff (1.9 KB) - added by boonebgorges 8 years ago.

Download all attachments as: .zip

Change History (5)

@boonebgorges
8 years ago

#1 @boonebgorges
8 years ago

  • Keywords has-patch needs-review added
  • Owner set to boonebgorges
  • Status changed from new to assigned

37545.diff contains tests for array vs string values, as well as a simple fix.

Ping @ocean90 for review.

#2 @ocean90
8 years ago

  • Keywords commit dev-reviewed added; needs-review removed

37545.diff looks good to me. Core does the same in get_terms(). (The extra check for null is superfluous.)

#3 @boonebgorges
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 38181:

In WP_Term_Query, accept a string value for taxonomy.

Props endocreative.
Props ocean90 for review.
Fixes #37545.

#4 @boonebgorges
8 years ago

In 38182:

In WP_Term_Query, accept a string value for taxonomy.

Merges [38181] to the 4.6 branch.

Props endocreative.
Props ocean90 for review.
Fixes #37545.

Note: See TracTickets for help on using tickets.