WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] add_submenu_page calls all functions wierdness (2 posts)

  1. ianhaycox
    Member
    Posted 5 years ago #

    I've created submenus sucessfully but selecting any sub menu option calls ALL the submenu functions not just the one defined for the submenu. E.g.

    class myadmin extends myplugin {
      function addmenus() {
        add_menu_page('top','top',10,__FILE__,array($this,'top'));
        add_submenu_page(__FILE__,'sub1','sub1',10,__FILE__,
         array($this,'sub1'));
        add_submenu_page(__FILE__,'sub2','sub2',10,__FILE__,
         array($this,'sub2'));
      }
      function top() {echo 'top';}
      function sub1() {echo 'sub1';}
      function sub2() {echo 'sub2';}
    }

    clicking on any menu option echos top sub1 sub2

    All the functions are called. This does not seem right. I expected
    either top OR sub1 OR sub2 to be echoed not all of them.

    Anyone have any ideas ? I've been searching and trying various combinations for hours and getting very frustrated.

    Thanks.

  2. peterlcole
    Member
    Posted 5 years ago #

    http://codex.wordpress.org/Adding_Administration_Menus#Sub-Menus

    The file section notes that the field must be unique for every sub-menu page.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.