• Skip to main content
  • Skip to primary sidebar

WordPress, Genesis Framework and Storefront customization tutorials

  • Archive
    • Genesis
    • WooCommerce
    • WordPress
  • Premium
  • Blog
  • About
    • Tools I Use
  • Contact
  • Login
Home » navmenu

navmenu

How to add custom menu item to the WordPress nav menu

2020-02-15 by Gabor 1 Comment

The content between the li tags could be anything You want!

For example shortcode for language switcher, social icons or custom text.

// =========================================================================
// ADD CUSTOM MENU ITEM TO THE WORDPRESS NAV MENU
// =========================================================================
function add_custom_menu_item ($items, $args) {
    $items .= '<li id="menu-item-5000" class="menu-item menu-item-type-post_type menu-item-object-page last">';
        $items .= 'Last Menu Item';
    $items .= '</li>';
    return $items;
}
add_filter( 'wp_nav_menu_items', 'add_custom_menu_item', 10, 2 );

Filed Under: WordPress Tagged With: nav, navmenu

Primary Sidebar

  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube
WP Rocket - WordPress Caching Plugin
UpdraftPlus Premium

Disclosure: Some of the links in this site are affiliate links. I will be paid a commission if you use this link to make a purchase.

  • Privacy Policy
  • Flames Design
© 2021 WP Flames - All Right Reserved