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:
Here’s a high-level overview of what the script attempts to do:
What I’ve Already Tried (Without Success):
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:
- Maintain the existing page ID.
- Set the page template to “Elementor Full Width.”
- Insert the full Elementor content data from my master page.
- 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”).
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.
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.
Last edited: