To change the URL of the header image to use HTTPS
, you can use jquery to target the element that contains the header image and update its src attribute. You can add this jquery script to your themes js file or directly to your WordPress theme's footer.
WP themes already include jQuery, but if yours does not, you can enqueue it in your themes functions.php
file first.
function my_theme_enqueue_scripts() {
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'my_theme_enqueue_scripts');
once jQuery is loaded, you can add a script to update the header image URL to use HTTPS. Use a functions.php
file inside your theme (or child theme if exists) template add this code below.
function add_this_script_footer() {
?>
<script>
jQuery(document).ready(function($) {
// Target the header image element using its class or ID
var headerImage = $('.parallax-header-image');
// Check if the header image exists
if (headerImage.length) {
// Get the current image URL
var imageUrl = headerImage.attr('src');
// Replace 'http://' with 'https://' in the image URL
var secureImageUrl = imageUrl.replace('http://', 'https://');
// Update the header image URL to use HTTPS
headerImage.attr('src', secureImageUrl);
}
});
</script>
<?php }
add_action('wp_footer', 'add_this_script_footer');
Replace .parallax-header-image
with the appropriate selector for your header image element.
str_replace
to change http to https in a specific string. First you will need to find the code responsible for adding this image.