Jump to content

Need to exclude a link when a certain page is displayed.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
VilPietersen

VilPietersen

    Newbie

  • Members
  • Pip
  • 1 posts
Hey everyone,

This is my first post here and I've got a good one for anyone who enjoys php.

I want to be able to exclude a link in my menu on my wordpress blog when a specific page is loaded. (The menu isn't managed by the CMS, I manually typed it in to the header.php).

If I were going to write the code in english, it would sound like this.

if page = "THE PAGE IN QUESTION" then "THIS LINK" won't show.

I hope this is clear enough for you all, and I appreciate your help :thumbup1:

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
if ($page != "pagename") {
  echo '<a href="page">link</a>';
}

__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
You could also use server variables to get the page name:

<?PHP
if($_SERVER['REQUEST_URI'] != "/page.html") {
  echo '<a href="page">link</a>';
}