WordPress.org

Ready to get started?Download WordPress

Forums

Sandbox Menu Depth Level (2 posts)

  1. damatthew
    Member
    Posted 2 years ago #

    Hi all,

    I've been writing a theme based on the Sandbox theme and have been stumped with how the menu function in Sandbox works. I'm trying to make the menu show top level pages only, rather than including sub-page dropdowns, which appears to be the default in Sandbox.

    I thought this would be a relatively straight forward issue by simply adding "depth=1" to the menu function in functions.php, but for some reason when I do that, the sub menus still appear. I'm going to need to add dynamic menu highlighting after this, which is why I'm trying to resolve this issue by editing the function rather than simply using WordPress's menu widget.

    If anyone has any suggestions, I'm all ears. Thanks!

    The URL of my test site is icalanguages.com/beta and the following is the code in question:

    function sandbox_globalnav() {
    	if ( $menu = str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages('depth=1&title_li=1&sort_column=menu_order&echo=0') ) )
    		$menu = '<ul>' . $menu . '</ul>';
    	$menu = '<div id="menu">' . $menu . "</div>\n";
    	echo apply_filters( 'globalnav_menu', $menu ); // Filter to override default globalnav: globalnav_menu
    }
  2. bkjproductions
    Member
    Posted 2 years ago #

    Couldn't you just do this with CSS? Maybe create a rule that hides all of the children of the menu?
    .children {display: none;}

Topic Closed

This topic has been closed to new replies.

About this Topic