How to replaced html http all links with https request in WordPress

Simply add this code into functions.php

function dandd_force_https() {
    if ( empty( $_SERVER['HTTPS'] ) ) return;
    ob_start();
}
add_action( 'template_redirect', 'dandd_force_https', 1 );

function _bd_output_https_page()
{
    if ( empty( $_SERVER['HTTPS'] ) ) return;
    echo str_ireplace( 'http://', 'https://', ob_get_clean() );
}
add_action( 'wp_footer', 'dandd_output_https_page', 99 );

Leave a Reply

Your email address will not be published.