下面是一些javascript,希望能在当前徽标的右上角添加一个新链接。您需要将此脚本添加到主题中。
我已经添加了一些评论来解释我所做的事情,但如果不清楚,请随时问我任何问题。
<script>
// Create a div element with class secondary-logo which will contain the secondary link inside.
var secondary_logo_link = document.createElement(\'div\');
secondary_logo_link.className=\'secondary-logo\';
// Add the secondary link (replace https://www.google.com with your desired url) to the new container element. Also adding custom CSS styling to help position/size the new element correctly.
secondary_logo_link.innerHTML = \'<a href="https://www.google.com"></a><style>.logo{ position:relative; }.secondary-logo{position: absolute; top: 0; right: 0; width: 27%; height: 100%; z-index: 1;}.secondary-logo a{height: 100%; width: 100%;}</style>\';
//Finally append the new secondary-logo element to both occurances of the logo (header and sticky).
document.getElementsByClassName(\'logo\')[0].appendChild(secondary_logo_link.cloneNode(true));
document.getElementsByClassName(\'logo\')[1].appendChild(secondary_logo_link.cloneNode(true));
</script>