How to fix mixed content after switching to HTTPS
To fix mixed content, find the images, scripts and styles that an https page still loads over plain http and move them to https. Until then the browser shows a padlock with a warning or blocks those resources, and the layout can break. Do it right after the switch to HTTPS.
Check your site
-
Find what is loading over http
Open the site, press F12 and look at the Console tab: the browser names mixed content there and gives the exact file URLs. Chrome DevTools also lists them under the Security tab.
-
Replace http links in your content
Most of them are hard-coded links in posts and the theme. Run a database replace (Better Search Replace or WP-CLI search-replace) from http://your-domain to https://your-domain.
-
Check the template and theme settings
Look in header.php, footer.php and the theme options: logos, background images and font includes often have absolute http URLs. Change them to https.
-
Fix external resources
If a third-party script or font loads over http, switch to the https URL of the same source. If the source has no https, find a replacement: modern browsers block such scripts, and for images and media they try https and block the file if that fails.
-
Add a safety-net header (optional)
A Content-Security-Policy header with the upgrade-insecure-requests directive makes the browser fetch http resources over https. It is a fallback, and the links still need fixing.
-
Clear the cache and check again
Purge the page cache, LiteSpeed Cache and the CDN, then reload with Ctrl+F5. Test several page types: the home page, an article, a product page.
How to verify the result
The padlock should have no yellow triangle and the Console no mixed content messages. Run the site through the SpoofLens security headers check to confirm a proper CSP is in place.
Tip: Do not silence the browser warning or ignore blocked scripts: because of them, forms, sliders and analytics can stop working unnoticed.