Home Forums ACF PRO ACF Field menu walker


ACF Field menu walker

    • Trint33

    • November 27, 2020 at 9:07 pm

    Hello everybody,
    this is my first thread since I’m using ACF pro (about 4 years ;-).
    I created two customs fields for my menu, the first one is a color picker and the second one is select so as to the <ul> columns number.
    I created a new walker so as to have a div before my <ul> and change <ul> class.
    The walker works, Menu display as I want but, I don’t find how to display ACF fields.

    Here are my functions :

      function start_lvl( &$output, $depth = 0, $args = array() ) {
        $indent = str_repeat("\t", $depth);
        $output .= "\n$indent<div class=\"sub-menu\">\n";
        $output .= "\n$indent<ul class=\"column\">\n";
      function end_lvl( &$output, $depth = 0, $args = array() ) {
        $indent = str_repeat("\t", $depth);
        $output .= "$indent</ul>\n";
        $output .= "$indent</div>\n";

    My goal is to create a style=”background-color:ACF color field”; to sub-menu div and add ACF column class to column ul.

    Any help is really appreciated.



    • Trint33

    • November 27, 2020 at 11:24 pm

    I reach to display color on the ancestor with the function start_el but not to the sub-menu div and add ACF column class to column ul…

      function start_el(&$output, $item, $depth=0, $args=array(), $id = 0) {
        $object = $item->object;
        $type = $item->type;
        $title = $item->title;
        $description = $item->description;
        $permalink = $item->url;
        $color = get_field('couleur_menu', $item->ID);
        $output .= "<li class='" .  implode(" ", $item->classes) ."' style=background-color:".$color.">";

    How can I do something close with function start_lvl ?

    • Trint33

    • December 1, 2020 at 7:26 pm

    nobody can help me on this ?


Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.