Frequently Asked Questions

FAQ / General

How to Fix the Mixed Content Error on WordPress

A mixed content error in WordPress typically occurs when a site is served over HTTPS, but some resources (such as images, scripts, or stylesheets) are still being served over HTTP. This can compromise the security of your website. Here are steps to fix mixed content errors in WordPress:

1. Identify Mixed Content

  • Browser Developer Tools: Use your browser's developer tools (usually accessible via F12 or right-clicking and selecting Inspect) to check the console for mixed content warnings.

  • Online Tools: Use online tools like Why No Padlock or SSL Checker to identify mixed content issues.

2. Update URLs in Settings

  • Go to Settings > General in your WordPress dashboard.
  • Ensure that both the WordPress Address (URL) and Site Address (URL) are set to https://yoursite.com.

3. Search and Replace URLs

  • Use a plugin like Better Search Replace to search for http:// and replace it with https:// in your database.
  • Alternatively, use SQL queries in phpMyAdmin to update URLs in the database.

4. Update Media URLs

  • Re-upload media files, or use a plugin like Velvet Blues Update URLs to update URLs in your media library.

5. Use a Plugin to Force HTTPS

  • Install and activate a plugin like Really Simple SSL. This plugin automatically detects your settings and configures your website to run over HTTPS.

6. Update Theme and Plugin Resources

  • Ensure that all resources (scripts, stylesheets) in your theme and plugins are loaded over HTTPS. You may need to update the code in your theme's functions.php file or in individual plugin files.

For example,

change php code from:

wp_enqueue_script('custom-script', 'http://example.com/script.js');

to:

wp_enqueue_script('custom-script', 'https://example.com/script.js');

7. Check .htaccess File

  • Update your .htaccess file to enforce HTTPS. Add the following code to redirect all traffic to HTTPS:

Apache

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

8. Content Delivery Network (CDN)

  • If you're using a CDN, ensure that it's properly configured to serve content over HTTPS.

9. Clear Caches

  • Clear your browser cache, WordPress cache (if using a caching plugin), and CDN cache (if applicable).

10. Manual Checks

  • Manually inspect your site's code and replace any remaining http:// links with https://.

11. External Resources

  • If your site loads resources from external sites, ensure those resources are also available over HTTPS. If not, consider hosting them locally or finding HTTPS alternatives.

Following these steps should help you resolve mixed content errors on your WordPress site.