INVP::delete_attachment_orphans()
Deletes media that is managed by this plugin but not attached to a post.
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' => apply_filters( 'invp_query_limit', 1000, __METHOD__ ), ) ); foreach ( $attachments as $attachment ) { wp_delete_attachment( $attachment->ID ); }
Expand full source codeCollapse full source codeView on Github