WordPress.org

Support

Support » Themes and Templates » Problem with 'add_menu_page'

Problem with 'add_menu_page'

  • Having a problem with add_menu_page. Either I’m doing this wrong or (surprise surprise) the documentation is not correct. My goal is to add an options page for my theme which will set on the menu. The documentation for doing this recommends:

    add_action('admin_menu', 'register_custom_menu_page');
    
    function register_custom_menu_page() {
       add_menu_page('custom menu title', 'custom menu', 'administrator', 'myplugin/myplugin-index.php', '',   plugins_url('myplugin/images/icon.png'), 6);
    }

    That is the ‘official’ wordpress example. If you use that code, though, you will find the menu links to myplugin/myplugin-index.php relative to the wp-admin directory, where no plugin should ever live.

    So for the example provided in the codex documentation, clicking the menu would take you to:

    http://blogaddress.com/wp-admin/myplugin/myplugin-index.php

    I’m pretty sure we would want something like:

    http://blogaddress.com/wp-content/plugins/myplugin/myplugin-index.php

    no?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with 'add_menu_page'’ is closed to new replies.