Select author automatically in Wordpress importer

131
March 09, 2022, at 1:20 PM

If you're importing posts to Wordpress and the author is already on the new Wordpress, there is no default way to select the author in the list.

To automatically select the correct author in the list, you can run this script in console.

$('#authors li').each(function() {
    $element = $(this);
    $select = $element.find("select");
    author = $(this).find("strong").html();
    
    IDToSelect = 0;
    $element.find('select option').each(function() {
        option = $(this).html();
        if (option == author) {
        IDToSelect = $(this).attr("value");
    }
    });
    $select.val(IDToSelect).change();
});

If you haven't jquery enabled in console, first run this:

var script = document.createElement('script');
script.src = "https://code.jquery.com/jquery-3.4.1.min.js";
document.getElementsByTagName('head')[0].appendChild(script);
Rent Charter Buses Company
READ ALSO
price depend on selection of radio input

price depend on selection of radio input

I tried but can't get it after this so please help me with this

135
How to call a JavaScript method based on the Advanced Custom Field's value in WordPress?

How to call a JavaScript method based on the Advanced Custom Field's value in WordPress?

I have a custom field in the form of a checkbox in my WordPress website's admin panelI want to load different JavaScript methods based on the selection of this checkbox

127
Retrieve the value of a variable that stores in local storage the options chosen by users in a dropdown list

Retrieve the value of a variable that stores in local storage the options chosen by users in a dropdown list

I need to retrieve the value of a variable that stores in local storage the options chosen by users in a dropdown list in order to use it elsewhere

144
Javascript function doesn't work when chrome auto-fill forms

Javascript function doesn't work when chrome auto-fill forms

I have a login form where, if the fields are filled with data, a javascript (jquery) adds a class to them

134