Wrote a dev console script code so it can help me replace “Focus keyword” with title of post

[ad_1]

If you are a rank math user, it may help you. It does not save. But just replaces "focus keyword". You need to run it after clicking on pencil icon of "SEO Details"

// Find all tr elements with class "type-page"
const typePageRows = document.querySelectorAll('tr.type-page');

// Loop through each tr element
typePageRows.forEach(row => {
    // Find the "row-title" link and get its text content
    const rowTitleLink = row.querySelector('a.row-title');
    if (rowTitleLink) {
        // Get the link text, remove "—" characters, and trim
        let linkText = rowTitleLink.textContent;
        linkText = linkText.replace(/—/g, '').trim();

        // Find the "rank-math-column-value" input and set its value
        const rankMathInput = row.querySelector('input.rank-math-column-value');
        if (rankMathInput && linkText) {
            rankMathInput.value = linkText;

            // Trigger an 'input' event to ensure any listeners are notified of the change
            const event = new Event('input', { bubbles: true });
            rankMathInput.dispatchEvent(event);
        }
    }
});

console.log('Script execution completed.');

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer