Execute php command based on what page isn’t active
-
I realize the topic title is a little confusing, so I’ll try to explain it a little better.
I have a ul that contains my navigation and I want to append a class of ‘active’ when a series of pages are not displayed. I’ve tried the following code, but it, and different variations of it, do not seem to work.
<li><a href="/news"<?php if (!is_home() || !is_page('about') || !is_page('past_conferences') || !is_page('upcoming_conferences') || !is_page('contact') || !is_page('join')) : ?> class="active" <?php endif; ?>>News</a></li>
I am using wordpress as a CMS with only one “Page” (News) containing the blog where the rest of the pages have static content but can be updated/changed through WordPress. Whenever a page that would be part of the blog (except the defined pages in the code) is active, I want that link to be active. I’ve tried using is_page_template(‘template.php’) where “template.php” is replaced with the different templates used to format the blog. This doesn’t seem to work. I’ve also tried wrapping the ! in () outside of the condition as follows:
if (!(is_home()) || !(is_page('about')))
but that doesn’t seem to work either. If anyone knows how I can check to see if specific pages are not active then continue the loop, that’d be great.Thanks,
– Heath G.
- The topic ‘Execute php command based on what page isn’t active’ is closed to new replies.