In my theme I have menu for max 2 levels. Now I want prevent to create more than 2 levels menu in admin dashboard. Is there any way to do that?
-
Hey Damian, did my answer help you solve your problem? – Fabian Marz Oct 24 '18 at 7:12
I investigated the codebase a bit and found a globalMaxDepth
option in wp-admin/js/nav-menu.js
.
When calling wpNavMenu.options.globalMaxDepth = 1
from the browser console in /wp-admin/nav-menus.php
you are no longer able to nest more than one level per drag and drop.
To achieve your goal you can now use admin_enqueue_scripts
to add a JS file to your backend which calls this code.
Hope this helps!