Exclude hyperlinks depending on which page is loaded on WordPress...

8 replies
Hey everyone,

I've got a question for anyone with a pit of php knowledge.

I'm wanting to exclude certain hyperlinks from my site, but only on one page.

I can picture the code but I can't get it to work.

I'm looking for something like this:

<a href ="link"> unless <page ="x"> (in which case the link doesn't show.)

If anyone can translate my english into php, I would be soooo greatful

Thanks warriors, you're all awesome
#depending #exclude #hyperlinks #loaded #page #wordpress
  • Profile picture of the author osegoly
    You could try something along these lines (my PHP is a little rusty these days):

    if($SERVER["REQUEST_URL"])!=your_page{echo your_link;}

    hope that helps.
    {{ DiscussionBoard.errors[2288541].message }}
  • Profile picture of the author VilPietersen@
    Thanks dude, I'll give it a blast
    Signature
    I build and deploy smart AI "customer service" ChatBots
    {{ DiscussionBoard.errors[2288555].message }}
  • If I understand you correctly, here's the code that displays the link on all pages except for the one:

    Code:
    <?php if(!is_page('Your Page')){?>
    <a href="http://www.yourdomain.com">Link</a>
    <?php }?>
    {{ DiscussionBoard.errors[2288755].message }}
    • Profile picture of the author VilPietersen@
      Originally Posted by Chris Landrum View Post

      If I understand you correctly, here's the code that displays the link on all pages except for the one:

      Code:
      <?php if(!is_page('Your Page')){?>
      <a href="http://www.yourdomain.com">Link</a>
      <?php }?>
      Mate!!! Thanks man, I've been messing with that for ages!!!

      One more thing, I need it to be
      HTML Code:
      echo " id="current""; ?>>
      When it isn't the page in question
      Signature
      I build and deploy smart AI "customer service" ChatBots
      {{ DiscussionBoard.errors[2289020].message }}
  • Profile picture of the author shadoo
    thank uuuuu
    {{ DiscussionBoard.errors[2288848].message }}
  • Profile picture of the author VilPietersen@
    Actually scratch that, Don't know what I was thinking...

    It works, but it isn't matching the other links in the menu, here's an example of the code that the other menus are

    HTML Code:
    <li<?php if (is_page('module-1')) echo " id="current"";  ?>><a  href="http://mysite.com/module-1"  title="module1"><span>Module  1</span></a></li>
    Is there anything I could do to that code to make it look like the other menu items?

    REALLY APPRECIATE YOUR HELP...
    Signature
    I build and deploy smart AI "customer service" ChatBots
    {{ DiscussionBoard.errors[2289052].message }}
  • Profile picture of the author VilPietersen@
    I figured it out...

    It was in <span></span> brackets...

    Thanks though you're a life saver!!!
    Signature
    I build and deploy smart AI "customer service" ChatBots
    {{ DiscussionBoard.errors[2289068].message }}
  • You're welcome. I'm glad it now works for you.
    {{ DiscussionBoard.errors[2291542].message }}

Trending Topics