Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function extract_attachment_ids($post) {
- $reslt=[];
- $attachments=wp_get_attached_media('',$post->ID);
- if (count($attachments)) {
- array_push($reslt, array_map(function ($o) {return $o->ID;},$attachments);
- }
- return $reslt;
- }
- /* array for id of images to be deleted */
- $rosies_images_to_be_deleted = [];
- $args = array(
- 'posts_per_page' => '999',
- 'post_type' => 'product'
- );
- $my_query = new WP_Query($args);
- if ($my_query->have_posts()) {
- while ($my_query->have_posts()) { $my_query->the_post();
- array_push($rosies_images_to_be_deleted, ... extract_attachment_ids($post));
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment