Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function streamtube_delete_child_video_posts( $postid, $post ){
- if( in_array( $post->post_type, array( 'video', 'attachment' ) ) ){
- $child_posts = get_posts( array(
- 'post_parent' => $post->ID,
- 'post_type' => 'attachment',
- 'posts_per_page' => -1
- ) );
- if( $child_posts ){
- foreach( $child_posts as $child ){
- wp_delete_attachment( $child->ID, true );
- }
- }
- }
- }
- add_action( 'before_delete_post', 'streamtube_delete_child_video_posts', 999, 2 );
- add_action( 'delete_attachment', 'streamtube_delete_child_video_posts', 999, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement