ok so i have a nav menu with the top level of menu items being static pages. When you highlight or visit one of them there is a sub-menu that pops up. Each one of them has there own sub-menu and each sub-menu is full of custom taxonomy terms. Since WordPress will only give the current-menu-item class on an archive page i need to either add my own class or just add some custom css to show and highlight the term parent when viewing a single item.
My problem is I had the code working but then it quit working. See the code below
<?
$has_news = has_term('news');
if ($has_news)
echo '<style type=text/css>#navbar{display:block}';
else
echo '';
?>
This is related to one of my other questions but I figured it would best be suite under its own with different tags.
Related Question: Highlight nav menu terms
wpversion: 3.1.2
Problem is that you’d need to pass a
$post->ID
in order to notreturn false.
Better use
is_object_in_taxonomy($object_type, $taxonomy)
and fill both the term and the tax in the function. It returns(boolean)
, so simply add your class based on the result: