Category not validating conditions…
-
I have the following code:
if (is_category() || is_page('finds') || is_page('family')) { if(is_category('finds') || in_category('finds') || is_page('finds')) { $maincat = 'Finds'; } elseif(is_category('family') || in_category('family') || is_page('family')) { $maincat = 'Family'; } $maincat_nicename = strtolower($maincat); echo '<h2> CatName:'.$maincat.' CatNiceName:'.$maincat_nicename.'<br /></h2>'; }
Basically, the code checks to see if the page is a CATEGORY or a specific PAGE. Then, depending on the category or page name, it sets a variable ($maincat). Either the page is a PAGE or it IS a CATEGORY or is IN a CATEGORY (for example: it is either the category called ‘Find’, or it is IN a category called ‘Find’).
Most of the time, this code works fine. But, there is one category called ‘School-Age’ that is located in the ‘Family’ category that doesn’t work. When I go to that category page for ‘school-age’, it does NOT set the variable $maincat. It should satisfy the condition:
in_category('fort')
(because it is IN the ‘family’ category)and it should do the following:
$maincat = 'Family';
But, it is NOT echoing a value for $maincat.
Please help! I double-checked the administration and there is definitely a category in FAMILY called SCHOOL-AGE. Also, there are other categories that work fine.
- The topic ‘Category not validating conditions…’ is closed to new replies.