WordPress mixed content errorEven though the page is opened with HTTPS, an image, script or style file is still loaded from the HTTP address. The browser then either removes the lock icon or displays a "not secure" warning; It can completely block script and style files. Even if the SSL certificate is installed, a single http source is enough to trigger this warning.

Where does mixed content come from?

Before the site moved to SSL, every image and link added was saved in the database with an http address. These addresses do not change automatically when the certificate is installed. The most common sources are:

  • Images added to article and page content.
  • Logo, background and favicon addresses entered in the theme settings.
  • HTML codes and external service embeds in widget areas.
  • Hard-written http addresses in theme or plugin files.

Find resources

Open the page in the browser and look at the Console tab in the developer tools. Each line of mixed content indicates which file was requested via http:

Mixed Content: The page at 'https://www.alanadiniz.com/'
was loaded over HTTPS, but requested an insecure image
'http://www.alanadiniz.com/uploads/logo.png'.

This line tells you that the logo is still called with the http address. Check different templates separately, such as a homepage, a post, a product, and a contact page, as each template may load different resources.

Update addresses in database

The permanent solution is to replace the old addresses in the database with https once. If you're using WP-CLI, run it in trial mode first:

wp search-replace 'http://www.alanadiniz.com' 'https://www.alanadiniz.com' --dry-run
wp search-replace 'http://www.alanadiniz.com' 'https://www.alanadiniz.com'

The first command shows how many records will be changed, but it doesn't change anything. The second command applies the change. This tool handles serialized data correctly; Changing with plain SQL in phpMyAdmin may break theme and widget settings. Be sure to take a database backup before the process.

Redirect entire site to HTTPS

Once the addresses are corrected, visitors arriving via http should be permanently redirected to https. On the Settings, General page, the Address should start with WordPress and the Site Address should start with https. Adding a 301 redirect at the server level moves visitors and search engines from old links to the correct address. For routing logic 301 redirect You can look at our article.

Comparison of solution methods

MethodLongevityNotes
Search-replace in databasePermanentThe recommended method is to backup first
SSL correction pluginAs long as the plugin remains openPerforms additional processing on each page production
Edit the theme filePermanentRequired for fixed addresses, use child theme
Content-Security-Policy upgrade-insecure-requestsAs long as the server header remains openHelper for the remaining small resources

Example scenario

When a corporate site that has been working with http for years is switched to SSL, the home page appears locked, but a warning appears on most blog posts. The reason is that hundreds of images added to old articles are registered with the http address. A single search-replace fixes all the text; The logo address in the theme setting is also updated. The sitemap is then recreated and sent to Search Console with the https address.

Things to do for search engines

Once the migration to HTTPS is complete, the https version of the site must be validated as a separate property in Search Console or the domain name property must be used. The site map should be resubmitted with https addresses, and canonical tags should be checked to show https. The remaining http addresses in internal links form a redirect chain; Since the search-replace process corrects these links, scanning efficiency also increases. Watching the directory report at Search Console for a few weeks after the migration will allow you to see that http addresses have been replaced by https addresses.

Common mistakes

  • Relying on the plugin alone: Alerts come back when the plugin is closed.
  • Non-redundant search-replace: A misspelled address can disrupt the entire site.
  • Mixing www and non-www address: Choose a single preference and set up all redirects accordingly.

To complete the SSL transition and security headers WordPress security optimisation page.

Does mixed content affect SEO?

The page is still indexed, but the browser warning reduces visitor confidence and blocked resources can disrupt the proper display of the page.

Is it enough to fix it with a plugin?

The plugin changes the addresses while the page is being generated; permanent solution is to update the addresses in the database once.

Is search-replace risky?

In order not to corrupt the serialized data, it should be done with a tool suitable for WordPress and by taking a backup first.