Skip to content

Instantly share code, notes, and snippets.

View ashish8141's full-sized avatar

Ashish Jat ashish8141

View GitHub Profile
@ashish8141
ashish8141 / wp-author-import-auto-select.js
Created December 3, 2018 09:13 — forked from webercoder/wp-author-import-auto-select.js
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');