Lake Worth, FL
/** * Temporary Media Library CSV Export * Visit: /?ampro_media_export=1 * Remove this code after export. */ add_action('init', function () { if (!isset($_GET['ampro_media_export'])) { return; } if (!current_user_can('manage_options')) { wp_die('Unauthorized'); } $filename = 'ampro-media-export-' . date('Y-m-d') . '.csv'; header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=' . $filename); $output = fopen('php://output', 'w'); fputcsv($output, [ 'Attachment ID', 'File Name', 'File URL', 'Title', 'Alt Text', 'Caption', 'Description', 'Mime Type', 'Width', 'Height', 'Upload Date', 'Parent Post ID', 'Parent Post Title', 'Parent Post URL' ]); $attachments = get_posts([ 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => 'inherit', 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'DESC', ]); foreach ($attachments as $attachment) { $attachment_id = $attachment->ID; $url = wp_get_attachment_url($attachment_id); $file_path = get_attached_file($attachment_id); $file_name = $file_path ? basename($file_path) : ''; $meta = wp_get_attachment_metadata($attachment_id); $width = isset($meta['width']) ? $meta['width'] : ''; $height = isset($meta['height']) ? $meta['height'] : ''; $alt_text = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); $parent_id = $attachment->post_parent; $parent_title = ''; $parent_url = ''; if ($parent_id) { $parent_title = get_the_title($parent_id); $parent_url = get_permalink($parent_id); } fputcsv($output, [ $attachment_id, $file_name, $url, $attachment->post_title, $alt_text, $attachment->post_excerpt, $attachment->post_content, $attachment->post_mime_type, $width, $height, $attachment->post_date, $parent_id, $parent_title, $parent_url ]); } fclose($output); exit; });
This IDX Website is powered by Diverse Solutions 2026.