0

Using WordPress, I have two links in my Footer Widget.
One is a dofollow link and other is a nofollow link.

I need to display the dofollow on the homepage only, while the nofollow needs to be displayed on every subpage.

I’m wondering if this is possible with CSS, or if I need to use JQuery.

I’ve tried using the below code but have achieved nothing:

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

Any advice or feedback would be greatly appreciated.

Azametzin
  • 5,223
  • 12
  • 28
  • 46
Jack
  • 1
  • Are you editing the theme .php files? If so, you can use some functions to check if it is home or a different page. – Azametzin Mar 04 '20 at 13:10

1 Answers1

1

Since the page-id class is shown on body element usually, in CSS you can try this:

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

Other way to make it is editing the widget .php file and checking if it is home page or not using is_home() function.

<?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; ?>

You can also try to use is_front_page().

<?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; ?>
Azametzin
  • 5,223
  • 12
  • 28
  • 46