[wp-trac] [WordPress Trac] #15475: Proposed new function: wp_unset_object_terms

WordPress Trac wp-trac at lists.automattic.com
Thu Nov 18 20:04:31 UTC 2010


#15475: Proposed new function: wp_unset_object_terms
---------------------------+------------------------------------------------
 Reporter:  simonwheatley  |       Owner:                         
     Type:  enhancement    |      Status:  new                    
 Priority:  normal         |   Milestone:  Awaiting Review        
Component:  Taxonomy       |     Version:                         
 Severity:  normal         |    Keywords:  has-patch, dev-feedback
---------------------------+------------------------------------------------
 In order to remove a single term associated with an object, leaving it's
 other terms in the same taxonomy, you have to call
 ```wp_get_object_terms```, remove the terms you don't require from the
 array, then call ```wp_set_object_terms```. I propose a single function,
 ```wp_unset_object_terms```, which does this, applying relevant actions as
 it does.

 Use case: A "starring" system whereby a user can (un)star a post to
 (un)favourite it. Each user has their own term where their stars are
 stored. You can use ```wp_set_object_terms``` with the ```append```
 parameter (thanks for pointing that out Nacin) to "star" posts, but
 there's no simple way to "unstar" (and be sure that appropriate actions
 are run).

 The attached patch adds the proposed function. Feedback, obviously, is
 welcome.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15475>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list