Skip to content

Instantly share code, notes, and snippets.

@infn8
Last active November 25, 2016 21:09
Show Gist options
  • Save infn8/fec58ca9095da1880c71 to your computer and use it in GitHub Desktop.
Save infn8/fec58ca9095da1880c71 to your computer and use it in GitHub Desktop.
Ever import a Wordpress eXtended RSS file and get sick of setting all the authors in the import file to all the SAME authors in your site? if so open your console and run this code.
jQuery('ol#authors li').each(function(index, el) {
var $, theName, parts, theOption, theID;
$ = jQuery;
theName = $(this).find('strong').text();
parts = theName.split('(');
theName = parts[0];
theID = parts[1].replace(')', '').trim();
theOption = $(this).find('select option:contains(' + theName.trim() + ')');
if(theOption.length){
$(this).find('select').val(theOption.val());
} else {
$(this).find('select').val(0);
$(this).find('input').val(theID);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment