Wordpress custom menu structure


#1

Hi,

Need some help on wp coding.

I want to change the default wp_nav_menu structure on a theme.

The default menu function is in: wp-includes -> nav-menu-template.php

	function start_lvl(&$output, $depth) {
		$indent = str_repeat("\t", $depth);
		$output .= "
$indent
    "; }

    I want to change it to

	function start_lvl(&$output, $depth) {
		$indent = str_repeat("\t", $depth);
		$output .= "
$indent
    • "; }

      I don’t want to change this from nav-menu-template.php because it will means to go outside the theme files.

      Is there a posibility to rewrite this structure in functions file inside the theme.

      Thanks.


  • #2

    Have a look at wp_nav_menu() http://codex.wordpress.org/Function_Reference/wp_nav_menu


    #3

    You’ll want to use a custom walker.

    Kriesi has a great tutorial on it :slight_smile: http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output


    #4

    Can’t you just pass the new variable to the function? define it in your functions.php file and send that variable to the function start_lvl.

    I did something similar when I wanted to change the comments. The template was not part of the theme files but I was able to change what I wanted in the comment_form by doing thing

    comment_form(array( 'title_reply' => 'my title here' ));
    

    couldn’t something similar work in this situation?


    #5

    Thanks mates for your sugestions.

    @sevenspark Thank you for the tip, reading Kriesi tutorial fixed my problem immediately :slight_smile:

    Cheers.


    #6
    FamousThemes said

    Thanks mates for your sugestions.

    @sevenspark Thank you for the tip, reading Kriesi tutorial fixed my problem immediately :slight_smile:

    Cheers.

    Sure thing :slight_smile: