WordPress.org

Ready to get started?Download WordPress

Forums

Problem with 'add_menu_page' (3 posts)

  1. docarzt
    Member
    Posted 2 years ago #

    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?

  2. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    You should be using add_theme_page() for a Theme's settings page, rather than add_menu_page().

  3. docarzt
    Member
    Posted 2 years ago #

    I don't want my page to appear under appearances though. Also I'd still like to have an understanding of how add_menu_page is supposed to work./

Topic Closed

This topic has been closed to new replies.

About this Topic