Assign CSS ID to submenu
-
Hi!
With minor experience in coding, I have managed to create a navbar, and placed it in my header. It is a horizontal list that makes tabs. See code:
<li<?php if (is_page('ipod-och-itunes')) { echo " id=\"active\""; } ?>><a>/ipod-och-itunes">iPod och iTunes</a>
I assign a ID of “active” if e tab is chosen. So far som good. My challenge is to assign a ID to the sublevel menu. Se sublevel menu is created by the following code:
<?php // subpage has been selected if ($post->post_parent) { // show children of selected page $children = wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0&depth=1'); } // parent page has been selected // check if there are any child pages else { // show children of current parent page $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0&depth=1'); } // if there are subpages, print them if ($children) { ?> <div id="submenu-wrapper"> <div id="navlist"> <ul id="subnavlist"> <?php echo $children ?> </div><!-- subnavlist --> </div><!-- submenu-wrapper-->
So, how do I assign a ID of ‘subactive’ to a child if the child exists, and is chosen?
My ambition is to have the sam functionality as the menu in The wallstreet journal, that highlights both the parent and the child, if child is chosen.
To add on to the challenge, it would be nice i I could assign different ID’s to children. That is only to be able to adjust the leftmargin to align the submenu directly under the chosen parent/tab.Any suggestions? Or am I unclear in any way?
- The topic ‘Assign CSS ID to submenu’ is closed to new replies.