ThemeShaper Forums » Thematic

[closed]

Two-Tiered Conditional Navigation

(5 posts)
  • Started 10 years ago by tdzl
  • Latest reply from tdzl
  • This topic is resolved
  1. I'm trying to implement this tutorial for a two tier conditional navigation, but having some problems. I assume I have to filter out the superfish navigation to make it work. Can somebody please help me write the proper code for functions.php to make this work?

    http://www.darrenhoyt.com/2008/02/12/creating-two-tiered-conditional-navigation-in-wordpress/

    Any help would be much appreciated.

    Posted 10 years ago #
  2. Update:

    Here's my functions.php code:

    function remove_sfmenu () {
    	remove_filter('wp_page_menu','thematic_add_menuclass');
    }
    add_action('init', 'remove_sfmenu');
    
    function remove_wp_page_menu() {
    	 remove_action('thematic_access','wp_page_menu',optionalpostitionnumber);
    	}
    add_action('init','remove_wp_page_menu');
    
    function child_nav() {
    ?>
    	<ul id="nav">
    	<?php wp_list_pages('title_li=&depth=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 && is_page()) { ?>
    	<ul id="subnav">
    	<?php echo $children; ?>  
    
    	<?php } else { ?>
    	<?php } ?>
    <?php
    }
    add_action('thematic_access', 'child_nav');
    
    function child_menuclass($ulclass) {
    return preg_replace('/
    <ul>/', '<ul id="nav">', $ulclass, 1);
    }
    add_filter('wp_page_menu','child_menuclass');
    </ul>

    Here's the result.

    As you can see, the sub menu is displaying all child pages regardless of the parent page, and does not change as it's supposed to.

    Any ideas what I'm missing here?

    Posted 10 years ago #
  3. Hi tdzl,

    Remove all of those functions and replace them with these:

    function remove_thematic_access() {
    	 remove_action('thematic_header','thematic_access',9);
    	}
    add_action('init','remove_thematic_access');
    
    function child_nav() {
    	global $post;	?>
    
    	    <div id="access">
    
    	    	<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>"><?php _e('Skip to content', 'thematic'); ?></a></div><!-- .skip-link -->
    
    	    	<ul id="nav">
    		<?php wp_list_pages('title_li=&depth=1' ); ?>
    			</ul>
    
    		<?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 && is_page()) { ?>
    
    			<ul id="subnav">
    		<?php echo $children; ?>
    			</ul>
    		<?php } else {
    	} ?>
    
    		</div><!-- #access -->
    <?php }
    
    add_action('thematic_header', 'child_nav',9);

    -Gene

    Posted 10 years ago #
  4. Awesome, it worked! I had to edit the CSS a little to get the subnav on the 2nd line, but that was easy enough.

    Thanks, Gene!

    Posted 10 years ago #
  5. Question: What if I wanted to add child-pages of the blog for 'categories' and 'archives'. Nothing I've tried works. Any help would be greatly appreciated!

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.