My current code displays an linked image on the frontend of any WP website, I would like the link to dynamically change at the end to insert the current domain only, not the full URL.
I am currently use the below code, but can't find a way to get the domain only showing dynamically at the end of a set domain. As shown below the "CURRENTDOMAINHERE" should display the current domain with out the https:// and without any directory. EG: https://example.com/currentdomain.com
<?php
/**
* Add image to the bottom left of the frontend of the website
*/
function cwpai_add_image_to_frontend() {
?>
<style>
#image {
position: fixed;
bottom: 1em;
left: 1em;
z-index: 9999;
width: 100px;
}
</style>
<a href="https://example.com/CURRENTDOMAINHERE" id="image">
<img src="https://imagesrc.com/image.png" alt="image">
</a>
<?php
}
add_action( 'wp_footer', 'cwpai_add_image_to_frontend' );