• Hi all,

    I’m developing a plugin to manage some items (eg. Books with related Categories) in the Admin Panel. I added a Main Page (Books) in the menu and two Sub Pages (“Add Book” and “Book Categories”) and I get the pages without problem.

    The only problem is that when I open the subpages “Add Book” and “Book Categories”, the link in the submenu does’n get the class="current" style. The style remains always on the Main Page “Books”.

    This is the code… any suggestions?

    if (! function_exists('BK_TheMenu')){
    function BK_TheMenu(){
    $add_book_page = __FILE__ . "&action=ShowBooks";
    $cat_book_page = __FILE__ . "&action=BookCategories";
    add_menu_page('Books', 'Books', 8, __FILE__, 'BK_admin');
    add_submenu_page(__FILE__, 'Add Book', 'Add Book', 8, $add_book_page, 'BK_admin');
    add_submenu_page(__FILE__, 'Book Categories', 'Book Categories', 8, $cat_book_page, 'BK_admin');
    }
    }

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • it is because (sorry to all my english teachers for that one) all your menus point to the same page, __FILE__. thus when WP sets the “current page” it will be set to the filename of your plugin, and the Books menu, which comes first, will be highlighted (current).

    The solution is to put each of those sub menu pages in seperate files. like add-book.php and book-cats.php, or something like that. Then link your menus to those files. The main menu item, ‘Book’, can be handled by your main plugin file…

    Thread Starter Claudio Simeone

    (@mrbrown)

    Thank you very much! I’ll try to separate the pages.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_submenu_page and class=”current” not working’ is closed to new replies.