WordPress add_menu_page() Adding the "Theme page title" item to the nav bar


Example

Code

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

Output

enter image description here

Explanation

In the code, we created a function named add_the_theme_page and we used add_menu_page to add the item to the navbar. Please check the parameters part in this page to know about the arguments we passed in. Then we used add_action to run our add_the_theme_page function. Finally, we created the function page_content to display contents in the page.