Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dirkvw001

    (@dirkvw001)

    Hi Matt,

    Thanks for your quick response, i’ve used json_decode to handle the returned json gets me to where i need to be. I’m attempting to retrieve the field in a custom WordPress navigation walker class that extends the built-in Walker_Nav_Menu class. It’s not using the get_field or get_sub_field functions, and i don’t think it’s using get_post_meta either.

    I apologise if it’s not all that helpful, but here’s what the section of code looks like where i’m getting the icon data. It’s a fontawesome acf field shown in each menu item which has been added in a specific menu location:

    <?php

    class theme_nav_walker extends Walker_Nav_menu {
    private $current_item;

    function start_el(&$output, $item, $depth = 0, $args = null, $id = 0) {
    $this->current_item = $item;

    $args->link_before = '';
    if(!empty($item->menu_icon)) {

    $icon_field = json_decode($item->menu_icon, true);
    $icon_class = 'fa-'.$icon_field['style'].' fa-'.$icon_field['id'];

    $args->link_before = '<i class="'.$menu_class.'__icon '.$icon_class.'"></i>';

    }

    }
    }

    The fact i’m not using get_ functions probably explains the lack of formatting then, although it usually still returned the field in the format i specified in the settings.

    I can use json_decode to retrieve all the data i need from the returned json. It just seemed odd to me that the data it returned didn’t match the format i selected anymore.

    Encountering the exact same problem with the most recent update, everything else has been updated to the latest version including wordpress itself.

Viewing 2 replies - 1 through 2 (of 2 total)