Add a Menu Item to All Menus
Automatically add a specific menu item to all menus.
<?php
function add_menu_item_to_all_menus($items, $args) {
if ($args->theme_location == 'primary') {
$items .= '<li><a href="/special-page">Special Page</a></li>';
}
return $items;
}
add_filter('wp_nav_menu_items', 'add_menu_item_to_all_menus', 10, 2);
Post Comment