【发布时间】:2013-05-15 08:53:16
【问题描述】:
我正在为具有一些自定义设置的应用程序创建一个专用主题,这些设置将仅用于从全新的 wordpress 安装设置应用程序几次。
如何在 wordpress 管理中通过 functions.php 为 21 个子主题创建顶级菜单和包含设置的页面?我想把它作为菜单中的第一项。
【问题讨论】:
标签: wordpress wordpress-theming
我正在为具有一些自定义设置的应用程序创建一个专用主题,这些设置将仅用于从全新的 wordpress 安装设置应用程序几次。
如何在 wordpress 管理中通过 functions.php 为 21 个子主题创建顶级菜单和包含设置的页面?我想把它作为菜单中的第一项。
【问题讨论】:
标签: wordpress wordpress-theming
这里有一个解决方案。只需将此代码放在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'