Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在主页上显示dofollow,但在子页面上隐藏_Jquery_Css_Wordpress_Footer_Nofollow - Fatal编程技术网

Jquery 在主页上显示dofollow,但在子页面上隐藏

Jquery 在主页上显示dofollow,但在子页面上隐藏,jquery,css,wordpress,footer,nofollow,Jquery,Css,Wordpress,Footer,Nofollow,使用WordPress,我的页脚小部件中有两个链接。 一个是dofollow链接,另一个是nofollow链接 我只需要在主页上显示dofollow,而nofollow需要在每个子页面上显示 我想知道这是否可以通过CSS实现,或者我是否需要使用JQuery 我尝试过使用以下代码,但没有取得任何效果: .footer-dofollow:is(.page-id-123) { display: none; } 任何建议或反馈都将不胜感激。由于页面id类通常显示在body元素上,因此在CSS中,您可以

使用WordPress,我的页脚小部件中有两个链接。
一个是dofollow链接,另一个是nofollow链接

我只需要在主页上显示dofollow,而nofollow需要在每个子页面上显示

我想知道这是否可以通过CSS实现,或者我是否需要使用JQuery

我尝试过使用以下代码,但没有取得任何效果:

.footer-dofollow:is(.page-id-123) { display: none; }

任何建议或反馈都将不胜感激。

由于页面id类通常显示在body元素上,因此在CSS中,您可以尝试以下方法:

.page-id-123 .footer-dofollow {
  display: none;
}
.footer-dofollow {
  display: none;
}
.page-id-123 .footer-dofollow {
  display: inline;
}

另一种方法是编辑widget.php文件并检查它是否是主页,是否使用
is_home()
函数

<?php if (is_home()): ?>
  <a href="example.com" class="footer-dofollow">Link</alt>
<?php endif; ?>

<?php if (!is_home()): ?>
  <a href="example.com" class="footer-nofollow">Link</alt>
<?php endif; ?>

您正在编辑theme.php文件吗?如果是这样,你可以使用一些功能来检查它是主页还是其他页面。因此,我尝试了以下方法,但我在包括主页在内的所有页面上都收到了NoFollow链接。有什么想法吗“rel=”nofollow“>nofollow`通常取决于您的Wordpress主页配置。如果(!is_front_page())而不是如果(!is_home()),请尝试
<?php if (is_home()): ?>
  <a href="example.com" class="footer-dofollow">Link</alt>
<?php endif; ?>

<?php if (!is_home()): ?>
  <a href="example.com" class="footer-nofollow">Link</alt>
<?php endif; ?>
<?php if (is_front_page()): ?>
  <a href="example.com" class="footer-dofollow">Link</alt>
<?php endif; ?>

<?php if (!is_front_page()): ?>
  <a href="example.com" class="footer-nofollow">Link</alt>
<?php endif; ?>