如何向WordPress管理子菜单列表项添加属性

时间:2015-10-30 作者:Amen Ra

我一直在试图找到一种方法,将类或id添加到我的自定义管理子菜单中。我只在第一个菜单项上看到一个类。我想在我的子菜单列表项上添加css类或ID。

1 个回复
最合适的回答,由SO网友:Amen Ra 整理而成

所以我找到了解决问题的办法。我刚刚添加了一个span 在add\\u submenu\\u page()挂钩中添加标签,它会起作用:

 add_submenu_page(
     # The slug for the parent menu page to which this sub menu belongs
     \'email-service\',
     # The text that\'t rendered in the browser title bar 
     \'Breaking News Email\', 
     # The text to be rendered in the menu
     \'<span class="breaking-news-toggle">Breaking News Email</span>\',
     # the capability required to access this menu item
     \'send_email\', 
     # The slug by which this sub menu is identified
     \'my-email-service\', 
     # the function used to display the options for this menu\'s page
     array(&$this, \'email_service_form\') 
   );