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

by 8 replies
10
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
#programming #depending #exclude #hyperlinks #loaded #page #wordpress
  • 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.
  • Thanks dude, I'll give it a blast
  • 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 }?>
    • [ 1 ] Thanks
    • [1] reply
    • 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
  • thank uuuuu
  • 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...
  • I figured it out...

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

    Thanks though you're a life saver!!!
  • You're welcome. I'm glad it now works for you.

Next Topics on Trending Feed