將主題頁面標題項新增到導航欄

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>';
}

輸出

StackOverflow 文件

說明

在程式碼中,我們建立了一個名為 add_the_theme_page 的函式,我們使用 add_menu_page 將項新增到導航欄。請檢查此頁面中的引數部分以瞭解我們傳入的引數。然後我們使用 add_action 來執行我們的 add_the_theme_page 函式。最後,我們建立了函式 page_content 來顯示頁面中的內容。