Skip to content

Instantly share code, notes, and snippets.

@SebKay
Created November 10, 2023 07:18
Show Gist options
  • Save SebKay/89e0f76a1b1aa57433355f9847a2e5c0 to your computer and use it in GitHub Desktop.
Save SebKay/89e0f76a1b1aa57433355f9847a2e5c0 to your computer and use it in GitHub Desktop.
<?php
global $wpdb;
$duplicates = $wpdb->get_results("SELECT PM1.meta_id, PM1.post_id, PM1.meta_key, PM1.meta_value, PM2.meta_id, PM2.post_id, PM2.meta_key, PM2.meta_value
FROM {$wpdb->postmeta} PM1, {$wpdb->postmeta} PM2
WHERE
PM1.meta_id > PM2.meta_id
AND PM1.post_id = PM2.post_id
AND PM1.meta_value = PM2.meta_value
AND PM1.meta_key = PM2.meta_key
-- AND PM1.meta_key = '_wp_attachment_image_alt'
ORDER BY PM1.post_id ASC LIMIT 1000 OFFSET 0");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment