This conserns two tables: “wp_extra_data” and “wp_posts”. wp_extra_data has the fields “id”, “post_id” and “post_title_md5”. Now I need to figure out how to retrieve duplicates from “post_title_md5” and then *delete from wp_posts where id = wp_extra_data->post_id except for the oldest post_id (aka the one with the lowest ID*
Example:
wp_extra_data may contain:
ID post_id post_title_md5
23 45 322a85c7502dfb2fce5bbd6794c00f81
56 92 322a85c7502dfb2fce5bbd6794c00f81
75 12 322a85c7502dfb2fce5bbd6794c00f81
In which case I’d want the script to “remove from wp_posts where id = 92 and 12”. So in short; how do I efficiently retrieve duplicates from wp_extra_data and then remove all of them except the one with the lowest key(ID). May be worth to note that I do not know what “post_title_md5” will be up front.
1 Answer