WordPress.org

Forums

[resolved] global_nav vs. wp_list_pages (6 posts)

  1. ads1018
    Member
    Posted 5 years ago #

    What's the difference?

  2. Adam Harley (Kawauso)
    Member
    Posted 5 years ago #

    What's global_nav? I can't find any trace of it in any WordPress function reference...

  3. ads1018
    Member
    Posted 5 years ago #

    It's in the sandbox theme. It's in the header. It seems to serve the same purpose as wp_list_pages.

  4. Adam Harley (Kawauso)
    Member
    Posted 5 years ago #

    From Sandbox's functions.php:

    // Produces a list of pages in the header without whitespace
    function sandbox_globalnav() {
    	if ( $menu = str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages('title_li=&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
    }

    So in essence, it's a wrapper for wp_list_pages and the difference is global_nav takes out the whitespace (line returns) in the output

  5. ads1018
    Member
    Posted 5 years ago #

    Thank you.

  6. stan@ibdev.com
    Member
    Posted 5 years ago #

    Digging a little deeper, how does the sandbox_globalnav function produce a horizontal menu? It is a list and a list is vertical. I would like to produce a menu that is horizontal for my parent pages and vertical for my child pages. I don't understand how to modify this function to achieve this effect. Any idea how to modify this function to do that? Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic