UPDATE wp_options SET option_value = replace( option_value, 'http://老域名', 'http://新域名' )
WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace( post_content, 'http://老域名', 'http://新域名' ) ;
UPDATE wp_posts SET guid = replace( guid, 'http://老域名', 'http://新域名' ) ;
// 更新图片链接
// 更新图片链接
function replace_image_urls($content) {
$pattern = '/<img([^>]*)data-original=["\']https?:\/\/img\.amjun\.com(.*?)["\'](.*?)>/i';
$replacement = '<img$1data-original="https://www.amjun.com$2"$3>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter('the_content', 'replace_image_urls');
function replacehttp($content){
$content = str_replace('http://ru.xx.com/wp-content/uploads', 'https://ru.xx.com/wp-content/uploads', $content);
return $content;
}
add_filter('the_content','replacehttp');
//if( is_ssl() ){ }
function replacehttp($content){
if( is_ssl() ){
$content = str_replace(‘http://域名/wp-content/uploads’, ‘https://域名/wp-content/uploads’, $content);
}
return $content;
}
add_filter('the_content','replacehttp');