Mixed content in the postmeta table

When WordPress creates a post, it saves all kinds of information about that post (a thumbnail, for example) within the wp_postmeta database table. If your theme then uses information from the postmeta table to insert an image, this can result in mixed content if the links have been saved as http:// instead of https://. Mixed content in the postmeta often does not result in mixed content on the frontend. To verify if the result creates mixed content, visit your site and check if the site has a secure lock. If so, this result can be safely ignored by pressing the ‘Ignore’ button in the scan results.

How to fix mixed content in the postmeta table

There are two types of mixed content on the postmeta table which both require a different approach. The approach depends on whether the file is coming from your own domain or from an external domain.

Fixing mixed content from your own domain in the postmeta table

Important note: we strongly recommend creating a backup of your site before making any changes to the database.

If the mixed content is coming from your own domain, you can safely replace the http:// link to your domain with https:// in the database.

There are a number of WordPress plugins that can do a search and replace on the database. This makes it relatively easy to replace an http:// domain with the https:// domain, thus fixing the mixed content. We like to use the Better Search Replace plugin. After installing and activating the Better Search Replace plugin, the replace functionality can be found in the Tools -> Better Search Replace menu.

There are three things you have to consider when fixing mixed content in the postmeta table. First, the ‘Search for’ field. This is your http:// domain. Secondly, the ‘Replace with’ field. This is your https:// domain. Finally, you can select in which table the replacing should be done. Since we’re looking at mixed content in the postmeta table, we’ll run the search and replace on the postmeta table only. Do note that while wp_postmeta is the default, you can also encounter a situation where wp_ is replaced by a different prefix, like x_58c90ee3 in the above example. This doesn’t matter, as long as the table ends with _postmeta.

After entering the above details you can press the ‘Run Search/Replace’ button do to a dry run. A dry run means that no replace will be done yet. Once the dry run has completed, the plugin will provide you with an overview of how many rows will be affected. If everything seems good, you can uncheck the ‘Run as dry run?’ option and press the Run Search/Replace button again to start the search/replace.

Fixing mixed content from an external domain in the postmeta table

When the mixed content is coming from an external domain, the search and replace can only be done if the file is available over https://. To test if this is the case, you can copy the URL from the scan result and try to load it over https://. Does it work? Then you can safely replace the http:// domain with https:// using the Better Search Replace method.

If the file is not available over https://, you can either contact the owner of the domain where the file is hosted to ask if they can make it available over https://, or host the image in your own media library if you have permission from the file owner.

Any questions? Send us a message and we’ll help you!

Lightweight plugin, Heavyweight Security features. Get Pro and leverage your SSL certificate for WordPress security standards.