WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently converted my WordPress installation to use SSL on all pages, and now I'm getting mixed content warnings. I've cleaned up everything in my themes and admin pages, but I'm still having trouble with embedded/attached content.

Most posts include uploaded images, and in the post_content those images are still referred to using an http:// URL. How can I permanently fix this and stop the mixed content warnings?

  • Should I try to fix all of the posts in the database so that they have correct https URLS?
  • Is there a way to dynamically rewrite posts as they are shown to use https URLS?
share|improve this question
This forum thread discusses why absolute links are used: wordpress.org/support/topic/… – Nic Nov 5 '11 at 20:09

Figured it out! The function I needed to hook is called "the_content", because that's the post content that is pulled directly from the database.

I added this code into the functions.php file for my theme.

function force_https_the_content($content) {
  if ( is_ssl() )
    $content = str_replace( 'src="http://', 'src="https://', $content );
  return $content;
add_filter('the_content', 'force_https_the_content');
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.