Managing menus in WordPress can quickly become frustrating — especially when you need to recreate the same structure for different pages, languages, or layouts.
By default, WordPress does not provide a built-in option to duplicate menus.
So what do most developers do?
Install a plugin
But here’s the problem:
Plugins add bloat, slow down performance, and increase maintenance.
In this guide, you’ll learn how to:
✔ Duplicate any WordPress menu instantly
✔ Add a “Duplicate Menu” button inside admin
✔ Avoid plugins completely
Why You Should Avoid Plugins for This
Using plugins like “Duplicate Menu” may seem easy, but:
- ❌ Adds unnecessary load
- ❌ Can break after updates
- ❌ Not optimized for custom workflows
If you’re building high-performance sites (like we do at KAS Web Technology), custom solutions are always better.
Step-by-Step: Duplicate Menu via Code
Step 1: Add Duplicate Button in Admin
Add this code to your theme’s functions.php:
<?php
add_action('admin_notices', function () {
global $pagenow;
if ($pagenow !== 'nav-menus.php' || !isset($_GET['menu'])) return;
$menu_id = intval($_GET['menu']);
$duplicate_url = wp_nonce_url(
admin_url('admin-post.php?action=duplicate_menu&menu_id=' . $menu_id),
'duplicate_menu_' . $menu_id
);
echo '<div class="notice notice-info">
<a href="' . esc_url($duplicate_url) . '" class="button button-primary">
Duplicate Menu
</a>
</div>';
});
?>
Step 2: Add Menu Duplication Logic
<?php
add_action('admin_post_duplicate_menu', function () {
if (!isset($_GET['menu_id'])) return;
$menu_id = intval($_GET['menu_id']);
if (!wp_verify_nonce($_GET['_wpnonce'], 'duplicate_menu_' . $menu_id)) {
wp_die('Security check failed');
}
$menu = wp_get_nav_menu_object($menu_id);
$new_menu_id = wp_create_nav_menu($menu->name . ' (Copy)');
$items = wp_get_nav_menu_items($menu_id);
$item_map = [];
foreach ($items as $item) {
$new_item_id = wp_update_nav_menu_item($new_menu_id, 0, [
'menu-item-title' => $item->title,
'menu-item-url' => $item->url,
'menu-item-status' => $item->post_status,
'menu-item-type' => $item->type,
'menu-item-object' => $item->object,
'menu-item-object-id' => $item->object_id,
'menu-item-parent-id' => 0,
]);
$item_map[$item->ID] = $new_item_id;
}
// Maintain hierarchy
foreach ($items as $item) {
if ($item->menu_item_parent) {
wp_update_nav_menu_item($new_menu_id, $item_map[$item->ID], [
'menu-item-parent-id' => $item_map[$item->menu_item_parent]
]);
}
}
wp_redirect(admin_url('nav-menus.php?action=edit&menu=' . $new_menu_id));
exit;
});?>
What This Solution Does
✔ Instantly duplicates menu
✔ Preserves dropdown structure
✔ Adds admin button
✔ No plugin required
✔ Lightweight & fast
Pro Tips (Advanced)
- Assign duplicated menu automatically to theme location
- Convert into reusable plugin (recommended)
- Add AJAX duplication (better UX)
- Combine with custom mega menu system
Yes, using custom code you can duplicate menus easily without installing any plugin.
Yes, it preserves full hierarchy including parent-child menu items.
Yes, it uses WordPress core functions and nonce security.
Want custom WordPress features like this?
KAS Web Technology specializes in:
- High-performance WordPress development
- News & content-heavy websites
- Custom Gutenberg-based themes
- Speed optimization solutions
Contact KAS Web Technology and build high-performance websites without plugin dependency.