• My module add items to custom menu dynamically. I faced with following problem – when I use add_filter

    add_filter( 'wp_get_nav_menu_items', 'myFunction', 20, 2 );

    this working only for non empty menus. If my menu is empty, this is not work. Of course I can add item to menu and this works, but maybe exist another sollution?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You can use the ‘pre_wp_nav_menu’ filter to output arbitrary content in place of the usual menu. Doing this probably only makes sense if there is no menu to output.

    Does it even make sense to add menu items if the user has no menu setup? I don’t know enough about your situation to answer this, but it is something to consider.

Viewing 1 replies (of 1 total)
  • The topic ‘Add item to empty custom menu’ is closed to new replies.