PHP-仅在主页上隐藏元素-WordPress网站

在我的footer.php文件中, 我在文件末尾有以下代码:

<?php wp_footer(); ?> 

<div class="website-by">
<br>
Website by <a href="https://gatewaywebdesign.com/" target="blank">Gateway Web Design</a>
</div>

</div>
</body>

如你所见, 我创建了一个”网站依据”链接, 单击该链接可以链接到另一个网站。

但我不希望此文本或包含该文本的div完全出现在网站的主页上:

https://thehamburgercollection.com/

我检查了其他建议使用JQuery进行操作的stackoverflow文章, 这些文章已添加到​​我的scripts.js文件中:

//hide link on the home page
document.ready(function() {
    if (window.location.href.indexOf('https://thehamburgercollection.com/')) {
      //Hide the element.
      jQuery('.website-by').hide();
    }
  });

我还尝试过使用建议的CSS将div隐藏在主页上:

.home .website-by {
    display: none;
}

但是不幸的是, 这些方法都没有起作用。我已经在footer.php文件中将我的类声明为website-by, 并在scripts.js文件中添加了以该类为目标的JQuery, 还添加了建议的CSS。知道为什么JQuery或CSS代码不起作用吗?

这是一个WordPress网站和一个自定义网站。任何帮助/建议/教育表示赞赏!


#1


我不是WordPress专家, 但你是否尝试在footer.php中执行if条件?如果我的问题正确无误, 则你需要.website-by不在首页以外的其他位置显示。也许像

<?php wp_footer(); ?> 

<?php if (!is_home()): ?>
    <div class="website-by">
    <br>
    Website by <a href="https://gatewaywebdesign.com/" target="blank">Gateway Web Design</a>
    </div>
<?php endif; ?>

</div>
</body>

来源:

https://www.srcmini02.com/63761.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37571.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?