I am trying to hook into the trash post function in the bulk menu.

I've managed to hook into an item when I trash it by it self by using the wp_trash_post hook, but this does not work when doing it in bulk.

Does anyone know how I can do this?

  • 2
    This is because accepts only 1 parameter i.e the post id codex.wordpress.org/Function_Reference/wp_trash_post Can I know what exactly you are trying to do? Also provide some code. Dec 7 '13 at 14:36
  • Ok, what I am trying to do is delete an associated post (product post type) when my custom post type (video) is deleted and vice versa. This works when I delete a video post by itself but not when using the bulk delete. I have actually disabled the trash, so only deleting happens, but I asked this question with the wp_trash_post as it also will not work.
    – Peter
    Dec 10 '13 at 5:30
  • add_action('before_delete_post', 'delete_post_from_video'); function delete_post_from_video() { global $post; global $wpdb; if ($post->post_type == 'video') { $check_attached_product = get_post_meta($post->ID, 'attached_product', true); if ($check_attached_product != "") { delete_post_meta($post->ID, 'attached_product', $check_attached_product); wp_delete_post( $check_attached_product ); } }
    – Peter
    Dec 11 '13 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.