INVP::delete_attachments( int $post_id )
delete_attachments
Contents
Description Description
Action hook callback. Deletes all a vehicle's attachments when the vehicle is deleted.
Parameters Parameters
- $post_id
-
(int) (Required)
Return Return
(void)
Source Source
File: includes/class-invp.php
public static function delete_attachments( $post_id ) { // Is $post_id a vehicle? if ( self::POST_TYPE != get_post_type( $post_id ) ) { // No, abort. return; } $attachments = get_posts( array( 'post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'posts_per_page' => -1, ) ); foreach ( $attachments as $attachment ) { wp_delete_attachment( $attachment->ID ); } }
Expand full source code Collapse full source code View on Github