Skip to content

Commit

Permalink
Fix slug bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ytwguru committed May 18, 2018
1 parent 27f2f44 commit 502d7a2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion includes/wp-api-menus-v2.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,20 @@ public function format_menu_item( $menu_item, $children = false, $menu = array()

$item = (array) $menu_item;

//categories, tags, etc ...
if($item['type'] === 'taxonomy')
{
$object_slug = get_term($item['object_id'], $item['object'])->slug;
}
//archive
else if($item['type'] === 'post_type_archive'){
$object_slug = get_post_type_object( $item['object'] )->rewrite['slug'];
}
else{
// post_type, page, etc ...
$object_slug = get_post( $item['object_id'] )->post_name;
}

$menu_item = array(
'id' => abs( $item['ID'] ),
'order' => (int) $item['menu_order'],
Expand All @@ -383,7 +397,7 @@ public function format_menu_item( $menu_item, $children = false, $menu = array()
'description' => $item['description'],
'object_id' => abs( $item['object_id'] ),
'object' => $item['object'],
'object_slug' => get_post( $item['object_id'] )->post_name,
'object_slug' => $object_slug,
'type' => $item['type'],
'type_label' => $item['type_label'],
);
Expand Down

0 comments on commit 502d7a2

Please sign in to comment.