Does this plugin still create menu endpoints or am I using the right endpoint?
https://mysite.com/menus/v1/menus
just returns a 404.
Hi, I’m getting the following error after upgrading to WP-REST API version 0.10
index.js:372 Uncaught (in promise) TypeError: Cannot read property ‘length’ of undefined
Here’s what’s going on around line 372:
classes.mainNavSecondaryLinks
)}>
{menuData?.secondary_links.length > 0 && <====== LINE 372
<ul>
{menuData.secondary_links.map((item, i) => {
if (!item.link) return (<></>);
]]>
The plugin generates the following error when using taxonomies:
Fatal error: Uncaught Error: Cannot use object of type WP_Term as array in /var/www/vhosts/[..]/httpdocs/wp-content/plugins/wp-rest-api-v2-menus/wp-rest-api-v2-menus.php:22
/**
* Get all registered menus
* @return array List of menus with slug and description
*/
function wp_api_v2_menus_get_all_menus() {
$menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) );
foreach ( $menus as $key => $menu ) {
// check if there is acf installed
if ( class_exists( 'acf' ) ) {
$fields = get_fields( $menu );
if ( ! empty( $fields ) ) {
$menu[ $key ]->acf = new stdClass();
foreach ( $fields as $field_key => $item ) {
// add all acf custom fields
$menus[ $key ]->acf->$field_key = $item;
}
}
}
}
return apply_filters('wp_api_v2_menus__menus', $menus);
}
On lines 22 and 26 the following code is used:
$menu[ $key ]->acf
but should be the following, I think:
$menu->$key->acf
Could anyone check if you can reproduce this? Try to add 20+ first level menu items (mostly taxonomy terms) and try to GET the data single menu by slug or id.
For me, it just keeps spinning.
]]>hi, how can I create menus via REST API is there a solution or reference to help me ???
]]>Hi,
I am sourcing menu from wordpress to gatsby.js with a help of your plugin.
I worked nicely..
..but after I updated wordpress to 5.5–pl_PL today, it looks the plugin does not push data to api.
Below graphQl query returns undefined ” allWordpressMenusMenusItems”
`{
allWordpressMenusMenusItems {
edges {
node {
id
name
items {
title
slug
post_title
url
}
}
}
}
}`
Simply “allWordpressMenusMenusItems” does not longer exist when I check my graphql feed on https://localhost:8000/___graphql
Could you test your plugin with the latest version of wordpress, please?
]]>Hello, is it possible to get items for only connected users?
]]>Hi!
After added URL of one of my WP media, the plugin return an object of the file instead of URL, and in GraphQL, we can’t have two different type of variable for the same name. So, how can I disable object for custom link ?
]]>Hi there.
The old API exposed a property called object_slug
which we rely on.
Actually I think a lot of people may need this.
We use the advantage of a REST API togehter with Vue and to use a vue router-link we can’t pass in the whole url together with the domain. So the bare object_slug
came in very handy.
Now in the new API there is nothing alike, am I correct?
Why was it removed and could it be re-added?
Thank you
Cheers
]]>Hi,
I have a three level menu (in my WordPress) that I want to retrieve in a PHP Symfony website.
Some time ago, I was able to get parent items, children and children of children.
Your plugin now returns parent items and their children but doesn’t support nested menu.
–> Is there a solution to get those children and their children ?
Thank you in advance ??
Fred
]]>Hi,
there’s a bug in a loop which assigns submenu items to their parents.
$child->menu_item_parent is not supposed to be a post name but post ID,
so line 95 should look like this:
if ($child->menu_item_parent == $item->ID) {
reference: https://developer.www.ads-software.com/reference/functions/wp_setup_nav_menu_item/
Cheers,
Piotr
This is version 2 of this plugin. Shouldn’t the namespace be v2?
/menus/v1/menus