• Hi People – hoping somebody can help me with this.

    I am trying to add an alternating style on my sidebar sub-nav list items – I have almost got it working – my problem is the $ children is generating it’s own
    li tags and styles – so I get n li element embedded in an li element – make sense?

    Here is the markup:

    <ul class="sidebar_list">
    		                     <li class="sidepanelbox">
    
                  <div class="header">
    				<h3>SUB-NAVIGATION</h3>
    			</div>
                 <div class="content">
    			<ul class="sub-nav">
                                         <li class="uneven"><li class="page_item page-item-67"><a href="#" title="The team">The team</a></li>
    </li>
                <li class="last">&nbsp;</li>
    
    			</ul>
                	</div>
                <div class="clr"></div>
                </li>
    </ul>

    Here is my code:

    <div id="content-left">
    	<ul class="sidebar_list">
    		<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar(1)) : ?>
            <?php
    			if($post->post_parent)
    			$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
    			$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    			if ($children) { 
    
    			?>
                 <li class="sidepanelbox">
                  <div class="header">
    				<h3>SUB-NAVIGATION</h3>
    			</div>
                 <div class="content">
    			<ul class="sub-nav">
                <?php $i = 0; ?>
                <?php $i++; ?>
                 <li <?php if($i&1) { echo 'class="uneven"';} else {echo 'class="even"';} ?>><?php echo $children; ?></li>
                <li class="last">&nbsp;</li>
    			</ul>
                	</div>
                <div class="clr"></div>
                </li>
    			<?php } ?>
    
    		<?php endif; ?>
    	</ul>
    </div>
    </div>

    Any help would GREATLY appreciated – and it might also help someone else trying to do similar things.

    Cheers,
    Simon

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘alternate style on sub-nav li items in sidebar’ is closed to new replies.