Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save apherio/95b8b7971846dc966881b491c1962f8d to your computer and use it in GitHub Desktop.
Save apherio/95b8b7971846dc966881b491c1962f8d to your computer and use it in GitHub Desktop.
Auto-select authors for posts during WordPress import. They must already be assigned to the project. Enable jQuery in a plugin or functions.php, and paste this in the browser console.
(function($){
$('#authors li').each(function(key, value) {
var name = $(this).children('strong').first().html();
var re = /\s\([^\)]+\)/gi;
name = name.replace(re, '');
$(this).find('select').first().children('option').each(function(){
if ($(this).html() == name) {
console.log('Comparing ' + $(this).html() + ' to ' + name + ".\n");
$(this).attr('selected', 'selected');
}
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment