我当前的代码在任何 WP 网站的前端显示链接图像,我希望链接在末尾动态更改以仅插入当前域,而不是完整的 URL。
我目前正在使用下面的代码,但无法找到一种方法让域只在一组域的末尾动态显示。如下所示,“CURRENTDOMAINHERE”应该显示没有 https:// 且没有任何目录的当前域。例如: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' );