Using Conditional Tags
-
I understand the basic concept of using conditional tags to display different content based on what page is being viewed. But I’m having some problems getting it to work the way I want it to. So, I have a “home.php” page, a “header.php”, a “footer.php” and a “sidebar.php”. So take this example. The “home.php” page is loading the “header.php,” “footer.php” and “sidebar.php.”
‘<?php if(is_home()) echo “<p’>You are on the home page now</p>”; ?>’
When I include this tag in the body of my “home.php” page it works fine. When I include it in my “header.php” it works fine. But when I include it in my “sidebar.php” or “footer.php” it doesn’t work. What would be different about it being included in the “sidebar.php” and “footer.php” that would cause this? Basically, I want to be able to display a different sidebar and/or footer depending on which page was being viewed. Thanks very much for any guidance or help.
- The topic ‘Using Conditional Tags’ is closed to new replies.