How I can hook function in class "Walker_Nav_Menu extends Walker"? (3 posts)

  1. viter-z-bayraku
    Posted 6 years ago #

    I need to modify function start_el of class "Walker_Nav_Menu extends Walker". add_filter hook added to function.php not working. How I can resolve it. Thank you!

  2. Jeremy Pry
    Posted 5 years ago #

    Not sure if you're still looking for the answer to this or not... However, walkers are a little bit different than filters or actions. You would need something like this in your functions.php:

    class Your_Class_Name extends Walker_Nav_Menu {
    function start_el(&$output, $item, $depth, $args) {
       /* Your custom code goes here.
        * I encourage you to copy the existing Walker_Nav_Menu
        * and then just make your changes.

    Then, when you call a menu in your template files, make sure to include 'walker' => new Your_Class_Name() in your array that specifies the arguments for wp_nav_menu().

    Hope that helps....

  3. monbouc
    Posted 5 years ago #

    Many thanks JPry !
    I don't know about viter-z-bayraku, but your comment made me save a good amount of time :)

Topic Closed

This topic has been closed to new replies.

About this Topic