HOW TO UPDATE POST CONTENT FROM AN XML FILE (WP-CLI over SSH) ============================================================== WHAT THIS DOES - The script reads a WordPress XML export file (WXR) and updates the content of posts that ALREADY exist on your site, matching them by post ID. - It does NOT create posts, delete posts, or change slugs, titles, dates or categories. After each update it checks that the slug and date are unchanged. - Only items with type "post" are processed. Pages and products are skipped. - The XML must come from the SAME website (post IDs must match). BEFORE YOU START - Take a full backup (hosting backup or a backup plugin). WordPress also keeps revisions of posts, but a backup is the safe option. - You need: the script (update-content-from-xml.php), your XML file, and a hosting plan with SSH access and WP-CLI (Hostinger has both). STEP 1: UPLOAD THE FILES - Upload BOTH files (the .php script and your .xml file) into your WordPress root folder, the folder that contains wp-config.php. - On Hostinger this is: domains/YOURDOMAIN.com/public_html (hPanel > Files > File Manager, or any FTP client such as FileZilla). - Both files must be in the same folder. STEP 2: ENABLE SSH - Log in to your hosting dashboard (hPanel). - Go to Advanced > SSH Access and turn SSH on. - Set an SSH password there. The page shows your connection command, which looks like: ssh -p PORT USERNAME@SERVER-IP STEP 3: CONNECT - Open a terminal (Windows: PowerShell or Windows Terminal. Mac: Terminal). - Paste the SSH command from the dashboard and press Enter. - Type your SSH password and press Enter. Nothing shows while you type, that is normal. STEP 4: GO TO YOUR WORDPRESS FOLDER - Run (replace YOURDOMAIN.com with your domain): cd domains/YOURDOMAIN.com/public_html - Check you are in the right place: ls You should see wp-config.php, your .php script and your .xml file in the list. STEP 5: PREVIEW (DRY RUN, SAVES NOTHING) - Run (replace YOUR-FILE.xml with your XML file name): wp eval-file update-content-from-xml.php YOUR-FILE.xml dry-run - Good result: lines starting with WOULD UPDATE, and a summary at the end. - Read the summary. If many posts say SKIP (not found), the XML is probably from a different site or the post IDs do not match. Stop and check. STEP 6: RUN IT FOR REAL - If the preview looks right, run the same command without "dry-run": wp eval-file update-content-from-xml.php YOUR-FILE.xml - Each post prints UPDATED and confirms the slug and date did not change. - If you see a WARNING line about slug or date, restore that post from backup/revision. STEP 7: CHECK AND CLEAN UP - Open a few posts on your site and check the content and links. - Clear your site cache (cache plugin / hosting cache). - Delete the .php script and the .xml file from public_html when finished, so they are not left publicly accessible. - Turn SSH off again in hPanel if you no longer need it. OPTIONAL - Run as a specific administrator (default is user ID 1): wp eval-file update-content-from-xml.php YOUR-FILE.xml dry-run 2 TROUBLESHOOTING - "wp: command not found": your host does not have WP-CLI. Ask support to enable it. - "This does not seem to be a WordPress installation": you are in the wrong folder. Use cd to reach the folder that contains wp-config.php. - "Please provide a valid path to the XML file": the file name is misspelled or the file is not in the folder you are in. Run ls to check. - Multiple WordPress sites on one hosting account: make sure the cd path is the domain you want to change.