• I’m trying to delete all attached files before a post is deleted.
    But hook called my function after a post is deleted.

    There is my code:

    function delete_post_children($post_id) {
        global $wpdb;
        if (get_post_type( $post_id )=="property") {
                $ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_parent = $post_id AND post_type = 'attachment'");
    
        foreach ( $ids as $id )
            wp_delete_attachment($id,true);
        }
    
    }
    add_action('delete_post', 'delete_post_children');

    This problem appears, after i updated to WP 3.2.1

    Can anyone help me ?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘delete_post hook problem in WP 3.2.1’ is closed to new replies.