By using Elementorforum.com’s services you agree to our Cookies Use and Data Transfer outside the EU.
We and our partners operate globally and use cookies, including for analytics, personalisation, ads and Newsletters.

  • Join the Best Wordpress and Elementor Support forum

    Provide or get advice on everything Elementor and Wordpress, ask questions, gain confirmation or just become apart of a friendly, like minded community who love Wordpress and Elementor


    Join us!

How to Automate Elementor Content Population & Dynamic Keyword Replacement for 140 Existing WordPress Pages?

emonunix

emonunix

New Member
Hello everyone,

I’m working on a large content update for a WordPress site and desperately need some expert insights. I’m trying to automate a very specific process and keep hitting a wall with a “Critical Error on this website.”

My Goal: I need to populate approximately 140 existing WordPress pages with content and design from one master Elementor page. For each of these 140 target pages, the process needs to:

  1. Maintain the existing page ID.
  2. Set the page template to “Elementor Full Width.”
  3. Insert the full Elementor content data from my master page.
  4. Perform a case-sensitive keyword replacement within the Elementor content:
    • My master page uses a specific placeholder keyword (e.g., “Nursing”).
    • Each target page has a title like “Get [Occupation] Jobs” (e.g., “Get Driving Jobs”).
    • For each page, the content needs to have “Nursing” replaced with the specific “[Occupation]” (e.g., “Driving”).
My Current Approach (Custom PHP Script): I’m attempting to achieve this automation using a custom PHP script that runs from the WordPress root directory.

Here’s a high-level overview of what the script attempts to do:

  • It fetches the Elementor data (JSON) directly from the master page’s post metadata.
  • To reliably handle very large data strings, it uses a separate initial script to extract this data, Base64 encode it, and save it to temporary .txt files on the server. The main automation script then reads these Base64 encoded strings from the .txt files.
  • The main script iterates through the 140 target page IDs, processing them in small batches to manage server resources.
  • For each target page in a batch:
    • It decodes the Elementor data from Base64 back to JSON.
    • It programmatically derives the unique keyword for that page from its title (e.g., “Driving” from “Get Driving Jobs”).
    • It recursively traverses the Elementor JSON structure and performs the case-sensitive replacement of the master keyword (“Nursing”) with the derived target keyword.
    • It clears the existing post_content.
    • It sets the page template.
    • It inserts the modified Elementor JSON data into the relevant WordPress post meta fields.
    • It sets the necessary Elementor flags for the page.
The Problem: Persistent “Critical Error” When I run the main automation script, even in small batches, the website immediately displays a “Critical Error on this website.” The script crashes before it can output any of its own messages. This makes it very difficult to diagnose the exact cause.

What I’ve Already Tried (Without Success):

  • Robust Data Handling: Using Base64 encoding/decoding and file-based reading for the Elementor JSON data to prevent issues with string length or copy-paste errors in the script itself.
  • Batch Processing: The script already processes pages in small batches to manage memory and execution time.
Any insights into why this “Critical Error” might be occurring, or alternative programmatic approaches for this task, would be greatly appreciated. Thank you for your time and help!
 
Last edited:
Elementor Services Elementor Services

Latest Resources

Other Elementor Resources

elementor official
Top