ThemeForest

Wordpress custom menu structure

114 posts Get in the spotlight
  • Author had a File in an Envato Bundle
  • Bought between 1 and 9 items
  • Elite Author
  • Europe
  • Exclusive Author
  • Has been a member for 3-4 years
  • Most Wanted Bounty Winner
  • Sold between 100 000 and 250 000 dollars
FamousThemes says

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 .= "\n$indent<ul class="\\"sub-menu\">\n";
    }
</ul>

I want to change it to

    function start_lvl(&$output, $depth) {
        $indent = str_repeat("\t", $depth);
        $output .= "\n$indent<li class="\\"menu_body\"><ul class="\\"sub-menu\">\n";
    }
</ul></li>

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.

27 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 10 000 and 50 000 dollars
piys says
2848 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 1000 and 1999 users
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+4 more
sevenspark moderator says

You’ll want to use a custom walker.

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

751 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • United States
CyberShot says

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?

114 posts Get in the spotlight
  • Author had a File in an Envato Bundle
  • Bought between 1 and 9 items
  • Elite Author
  • Europe
  • Exclusive Author
  • Has been a member for 3-4 years
  • Most Wanted Bounty Winner
  • Sold between 100 000 and 250 000 dollars
FamousThemes says

Thanks mates for your sugestions.

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

Cheers.

2848 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 1000 and 1999 users
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+4 more
sevenspark moderator says

Thanks mates for your sugestions.

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

Cheers.

Sure thing :)

by
by
by
by
by