将主题页面标题项添加到导航栏
码
function add_the_theme_page(){
add_menu_page('Theme page title', 'Theme menu label', 'manage_options', 'theme-options', 'page_content', 'dashicons-book-alt');
}
add_action('admin_menu', 'add_the_theme_page');
function page_content(){
echo '<div class="wrap"><h2>Testing</h2></div>';
}
输出
说明
在代码中,我们创建了一个名为 add_the_theme_page
的函数,我们使用 add_menu_page
将项添加到导航栏。请检查此页面中的参数部分以了解我们传入的参数。然后我们使用 add_action
来运行我们的 add_the_theme_page
函数。最后,我们创建了函数 page_content
来显示页面中的内容。