• Resolved enpinteractive

    (@enpinteractive)


    Hello, I am trying to add a new top level menu section in the admin menu sidebar using add_menu_page(). Here is my code which works fine:

    add_action('admin_menu', 'register_custom_menu_page');
    
    function register_custom_menu_page()
    {
    
    add_menu_page('custom menu title', 'Menu Name', 'add_users', 'themes.php?page=optionsframework', '', '../wp-content/themes/mytheme/images/admin/icon-favicon.png');
    
    }

    Where I need help is if someone changes the theme name from mytheme, my code will break. How can I make my code dynamic? Thank you!

Viewing 1 replies (of 1 total)
  • Thread Starter enpinteractive

    (@enpinteractive)

    Got it!

    add_action('admin_menu', 'register_custom_menu_page');
    
    function register_custom_menu_page()
    {
    	$icon_url = get_bloginfo('template_url') . "/images/admin/icon-favicon.png";
       add_menu_page('custom menu title', 'Menu Name', 'add_users', 'themes.php?page=optionsframework', '', $icon_url);
    }
Viewing 1 replies (of 1 total)

The topic ‘add_menu_page?’ is closed to new replies.