Make WordPress Core

Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#36690 closed enhancement (fixed)

Improve documentation on deleting all terms associated with an object

Reported by: barryceelen's profile barryceelen Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.8 Priority: normal
Severity: normal Version: 4.6
Component: Taxonomy Keywords: has-patch 2nd-opinion good-first-bug
Focuses: docs Cc:

Description

While looking for a way to delete all terms related to an object I first looked at wp_remove_object_terms(). That function however expects the slug(s) or ID(s) of the term(s) to remove as a parameter and cannot be used for removing all terms at once.

The right way to do this appears to be passing an empty array or null/false for the $terms parameter to the wp_set_object_terms() function.

It would be helpful to update the documentation of the wp_set_object_terms() function (or both).

Attachments (2)

36690.diff (1.4 KB) - added by barryceelen 9 years ago.
Updates the description of the $terms param
36690.1.diff (1.0 KB) - added by barryceelen 8 years ago.

Download all attachments as: .zip

Change History (10)

@barryceelen
9 years ago

Updates the description of the $terms param

#1 @barryceelen
9 years ago

  • Focuses docs added
  • Keywords has-patch added

This ticket was mentioned in Slack in #docs by morganestes. View the logs.


8 years ago

#3 @morganestes
8 years ago

I think we should avoid using mixed if we know exactly what to expect for a parameter's value, so @param array|int|string $terms is fine, but the order in the description should match the order of the types.

#4 @morganestes
8 years ago

  • Keywords 2nd-opinion good-first-bug added

@barryceelen
8 years ago

#5 @barryceelen
8 years ago

@morganestes Thanks for your feedback. I replaced mixed with array|int|string. Should there also be a reference added to wp_remove_object_terms()? That would probably be the first function one would look at when trying to delete all terms associated with an object.

#6 @SergeyBiryukov
8 years ago

  • Milestone changed from Awaiting Review to 4.7.2

#7 @SergeyBiryukov
8 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 39893:

Docs: In wp_set_object_terms(), add a note that passing an empty value as $terms argument will remove all related terms.

Props barryceelen.
Fixes #36690.

#8 @SergeyBiryukov
8 years ago

  • Milestone changed from 4.7.2 to 4.8
Note: See TracTickets for help on using tickets.