Skip to content

Instantly share code, notes, and snippets.

@dougblackjr
Created August 22, 2018 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dougblackjr/0d7bc193a07971a40dcf1d6f3bad3620 to your computer and use it in GitHub Desktop.
Save dougblackjr/0d7bc193a07971a40dcf1d6f3bad3620 to your computer and use it in GitHub Desktop.
Mass select authors by name in Wordpress import
var a = $('ol#authors li strong')
a.each(function(index, el) {
let b = $(el).text().split(' (')[0]
let c = $(el).closest('li')
let d = $(c[0]).find('div select option:contains("' + b + '")').val();
$(c[0]).find('div select').val(d)
});
@dougblackjr
Copy link
Author

OR, add them as new values:

var a = $('ol#authors li strong')
a.each(function(index, el) {
	let b = $(el).text().split(' (')[0]
	let c = $(el).closest('li')
	$(c[0]).find('div input').val(b)
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment