Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_delete_object_term_relationships [ WordPress Function ]

wp_delete_object_term_relationships ( $object_id, $taxonomies )
Parameters:
  • (int) $object_id The term Object Id that refers to the term
  • (string|array) $taxonomies List of Taxonomy Names or single Taxonomy name.
Uses:
  • $wpdb
Defined at:



Will unlink the object from the taxonomy or taxonomies.

Will remove all relationships between the object and any terms in a particular taxonomy or taxonomies. Does not remove the term or taxonomy itself.

Source


<?php
function wp_delete_object_term_relationships$object_id$taxonomies ) {
    global 
$wpdb;

    
$object_id = (int) $object_id;

    if ( !
is_array($taxonomies) )
        
$taxonomies = array($taxonomies);

    foreach ( (array) 
$taxonomies as $taxonomy ) {
        
$tt_ids wp_get_object_terms($object_id$taxonomy, array('fields' => 'tt_ids'));
        
$in_tt_ids "'" implode("', '"$tt_ids) . "'";
        
do_action'delete_term_relationships'$object_id$tt_ids );
        
$wpdb->query$wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)"$object_id) );
        
do_action'deleted_term_relationships'$object_id$tt_ids );
        
wp_update_term_count($tt_ids$taxonomy);
    }
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics