justinchrono Posted May 11, 2011 Share Posted May 11, 2011 Can somebody help me out with this? I am using Egesto as my theme, and automatically it came with a script that would highlight the current page in the top menu. i think the code is one of these lines.. '<?php if ( has_nav_menu( 'main-menu' ) ) { ?> <?php wp_nav_menu( array( 'theme_location' => 'main-menu', 'menu_class' => 'mainnav superfish' ) ); ?> ' Anyways, I wanted to make a customized drop down menu. So I removed that top line of code, and put in a line of code to refer to a plugin I downloaded. In the plugin is the HTML for the customized drop down menu...however, the current page is no longer highlighted in the menu.. I tried looking this up, seeing something about CSS and giving each link an id, and putting the id in the body tag of each page...HOWEVER, i can not find a body tag for each of my pages, as it is only in the HEADER of the overall website.. Can anyone help me with this? THANK YOU! Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted May 11, 2011 Share Posted May 11, 2011 well seeing just some php (in a html forum) wont help use. Anyway the most used technique for indicating where you are in a menu is by giving it a class. so often you will see that suddenly an item has a class of "active". See for instance the buttons of phpfreaks.com. If your in the forum the following is the markup for it: <a class="active firstlevel" href="http://www.phpfreaks.com/forums/index.php"> <span class="firstlevel">Forum</span> </a> as you can see it has both a class of active and first level. As far as sucker fish son of sucker fish, there are loads of tutorials on that. Anyway i hope you got the idea on how to indicate that a menu item is active. (by assigning a class) If you have no idea what i mean, get firebug for firefox, right click and inspect element. -> edit you might want to scroll down abit on this page: http://hostmonsterforum.com/showthread.php?5803-php-and-class-quot-active-quot-for-menu Seems someone wrote a nice function to do this. Quote Link to comment Share on other sites More sharing options...
justinchrono Posted May 12, 2011 Author Share Posted May 12, 2011 ^ thanks, but can you be a little more specific please? there is a lot of junk on that page that i am not following Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted May 12, 2011 Share Posted May 12, 2011 there are only 2 code snippets on that forum? And if your not following it, calling it junk is a bit odd. Anyway the folowing could be some thing to have a look at and adjust it to your needs $pages["home"] = "home page"; $pages["products"] = "our products"; $pages["contact"] = "contact us"; $active_page = $_GET["page"]; foreach($pages as $page => $page_title) { $suffix = ($page == $active_page) ? "_active" : ""; $nav.= "<a href='?page=".$page."' class='navigation".$suffix."'>$page_title</a>"; } print $nav; . Anyway the general idea is that you give a class to the menu button of for instance "active" tha n in css you just style that class. in php you can write a function to see what what page you are one, like the code above that assumes you have a $_GET variable http://yourdomain.com/index.php?page=home Hope this helps a bit. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.