How do I pass an argument to my custom walker?

Native walker are triggered with walk() method and are not set up to receive data on creation. You can define custom property and constructor method for this purpose:

class plus_walker extends Walker_Nav_Menu {

    var $refine;

    function __construct($refine) {

        $this->refine = $refine;
    }

}

//stuff

'walker' => new plus_walker('review');

After this you can access your custom data as $this->refine in walker’s methods.

Leave a Comment