【问题标题】:Create a top level menu in wordpress admin for a child theme在 wordpress admin 中为子主题创建顶级菜单
【发布时间】:2013-05-15 08:53:16
【问题描述】:

我正在为具有一些自定义设置的应用程序创建一个专用主​​题,这些设置将仅用于从全新的 wordpress 安装设置应用程序几次。

如何在 wordpress 管理中通过 functions.php 为 21 个子主题创建顶级菜单和包含设置的页面?我想把它作为菜单中的第一项。

【问题讨论】:

    标签: wordpress wordpress-theming


    【解决方案1】:

    这里有一个解决方案。只需将此代码放在functions.php中

    <?php
    /******* New menu item for admin *********/
    add_action( 'admin_menu', 'register_my_custom_menu_page' );
    
    function register_my_custom_menu_page(){
        add_menu_page( 'custom menu title', '♥Custom theme options♥', 'manage_options', 'custompage', 'my_custom_menu_page', '' /* or something like ... plugins_url( 'myplugin/images/icon.png' )*/, 1 ); 
    }
    
    function my_custom_menu_page(){
    ?>
    Hello world. This is a simple example page. 
    <?php
    }
    
    ?>
    

    【讨论】:

    • 删除plugins_url('myplugin/images/icon.png')并替换为get_stylesheet_directory_uri.'relative/path/to/icon.png'
    猜你喜欢
    • 1970-01-01
    • 2014-05-04
    • 1970-01-01
    • 1970-01-01
    • 2017-06-08
    • 1970-01-01
    • 2016-04-11
    • 2012-04-21
    • 1970-01-01
    相关资源
    最近更新 更多