Sunday 15 July 2012

php - How can I add a custom menu item to an existing Wordpress menu? -


I want to add a home icon as the first menu item in my Wordpress menu. How can I do this? To let you know, this code does not work:

  add_filter ('wp_nav_menu_items', 'your_custom_menu_item', 10, 2); ($ Items, $ args) {if_single () & amp; $ Args-> Theme_location == 'primary') {$ item. = '& Lt; Li & gt; Whatever looks & lt; / Li & gt; '; } Return $ item; }   

I have a function Php contains:

  add_theme_support ('nav-menus'); If (function_exists ('register_nav_menus')) {register_nav_menus (array ('main' = & gt; 'main main')); }   

And this is how I set the menu to fire:

     

You do not need to add filters and hooks for it.

You can edit your navigation in your theme files, usually it's in the header.php file. Add a new list item with your icon or text and insert a link for it. Plain HTML

No comments:

Post a Comment