Closed codepuncher closed 4 years ago
There is currently no way to get the Post ID for the related nav item. This prevents getting a field from a page in a menu.
Updating the parse method allows for this.
parse
protected function parse($items) { if (! is_array($items)) { return; } _wp_menu_item_classes_by_context($items); return $this->tree( collect($items) ->map(function ($item) { return (object) [ 'parent' => $this->hasParent($item), 'id' => $item->ID, + 'db_id' => $item->db_id, + 'object_id' => $item->object_id, 'label' => $item->title, 'slug' => $item->post_name, 'url' => $item->url, 'active' => $item->current, 'activeAncestor' => $item->current_item_ancestor, 'activeParent' => $item->current_item_parent, 'classes' => $this->filterClasses($item->classes), 'title' => $item->attr_title, 'description' => $item->description, 'target' => $item->target, 'xfn' => $item->xfn, ]; }) ); }
Thanks! If you had a chance, would you mind adding it to the readme example?
Sure, I'll submit a PR now!
There is currently no way to get the Post ID for the related nav item. This prevents getting a field from a page in a menu.
Updating the
parse
method allows for this.