Archive

Posts Tagged ‘menu’

Add menu into wordpress page

May 11, 2011 Leave a comment

Hello Folks,

Since many days i was wondering to add a dynamic menus that i could insert via plugin. I wanted to insert login and logout buttons into menu bar without editing the template. Then i found out one hook for the wordpress that i could inject my content into menu.

      add_filter('wp_nav_menu_items',add_menu,10,2);

The above hook will call add_menu which contain 2 parameters.

      function add_menu($items,$args)
      {
            items .= "<li>Another Menu</li>";
            return items;
      }

it will look as following


As you can see another menu is created beside. As css is not applied it looks like that apply css would
look alike.

If there is any problem give a reply.

%d bloggers like this: