jQuery To Select Duplicate Posts In WordPress Admin

I have to wade through masses of user submitted posts and it’s always a pain to try to spot duplicate submissions. I therefore came up with the following jQuery code that identifies duplicates (based on title) and selects all but the first, so I can then delete them.

	var titleArray = $('.row-title');
	for (i=0;i<titleArray.length;i++) {
		var thisTitle = $(titleArray[i]).text();
		for (j=0;j<titleArray.length;j++) {
			if (thisTitle == $(titleArray[j]).text() && i < j ){
				$('input',$(titleArray[j]).parent().parent().parent()).attr('checked', true);

I just have this running in a GreaseMonkey script, which has jQuery embedded into it as well. It’s a bit hacky – it only finds duplicates in the posts on the screen, not those on other pages – but it suits my needs just fine.

In the ideal world (if I had time), I’d turn it into a WordPress plugin and probably do it via PHP rather than JavaScript. Maybe in future!

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz: