Custom function for tabs creating duplicate tabs
//checks that we are on curr开发者_如何转开发ent page and highlights tab as active if so
if(is_page($page_name)){
echo " <li><a href='$href' class='current_page_item'> $tabname</a></li>";
}
else {
}
if(is_single() && $singlelight=="this_one") {
echo " <li><a href='$href' class='current_page_item'> $tabname</a></li>";
}
else {
echo " <li><a href='$href' > $tabname</a></li>";
}
The code above works as I expected - highlight tabs using the WordPress function is_single
and is_page
. The problem is it generates 2 tabs for the active one in the menu. So my menu looks like this when Home is active.
Home Home Faq Blog Contact
Appreciate any help.
Do you need the first if statement?
What if you tried:
if(is_single() && $singlelight=="this_one" && is_page($page_name)) {
echo " <li><a href='$href' class='current_page_item'> $tabname</a></li>";
}
else {
echo " <li><a href='$href' > $tabname</a></li>";
}
精彩评论