wp_delete_object_term_relationships example

function wp_delete_link( $link_id ) {
    global $wpdb;
    /** * Fires before a link is deleted. * * @since 2.0.0 * * @param int $link_id ID of the link to delete. */
    do_action( 'delete_link', $link_id );

    wp_delete_object_term_relationships( $link_id, 'link_category' );

    $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );

    /** * Fires after a link has been deleted. * * @since 2.2.0 * * @param int $link_id ID of the deleted link. */
    do_action( 'deleted_link', $link_id );

    

    do_action( 'before_delete_post', $postid$post );

    delete_post_meta( $postid, '_wp_trash_meta_status' );
    delete_post_meta( $postid, '_wp_trash_meta_time' );

    wp_delete_object_term_relationships( $postidget_object_taxonomies( $post->post_type ) );

    $parent_data  = array( 'post_parent' => $post->post_parent );
    $parent_where = array( 'post_parent' => $postid );

    if ( is_post_type_hierarchical( $post->post_type ) ) {
        // Point children of this page to its parent, also clean the cache of affected children.         $children_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid$post->post_type );
        $children       = $wpdb->get_results( $children_query );
        if ( $children ) {
            $wpdb->update( $wpdb->posts, $parent_data$parent_where + array( 'post_type' => $post->post_type ) );
        }
    }
Home | Imprint | This part of the site doesn't use cookies.