• pinkhare

    (@pinkhare)


    How could I refer a variable, which is outside a custom walker class(I think this is a loop), in a custom walker?

    I have to use a variable(array) in the walker, but it should be declared out of the walker(because the class file is a loop) and should be able to refer from outside the walker:

    $some_array = array();

    class Custom_Walker_Nav_Menu extends Walker {

    function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {

    // I want to use the variable ‘$some_array‘ here

    }
    }

  • The topic ‘How could I refer a variable outside a custom walker class in a custom walker’ is closed to new replies.