Ted
Ted

Reputation: 65

rewriting external links (WordPress)

I need to make photo hosting site external URL (http://ipic.su) to open over https protocol from my site. This photo hosting has both http and https versions, so sometimes my users post http links which causes mixed content warnings for users on my site.

I think this probably can be achieved by auto replacing http:// with https:// in URL using some function?

Upvotes: 0

Views: 683

Answers (1)

yivi
yivi

Reputation: 47319

You can use the_content filter.

E.g, a very simplistic approach:

function ipic_to_https_filter($content) {
  $new_content = str_replace('http://ipic.su', 'https://ipic.su', $content);
  return $new_content;
}

add_filter( 'the_content', 'ipic_to_https_filter' );

Upvotes: 2

Related Questions