Adding Sub-Menu on Existing Admin Menu with custom function.php

This topic contains 0 replies, has 1 voice, and was last updated by  Caezar De Castro II 7 months, 3 weeks ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #9442

    In this post or topic, our task is to add a new menu under an EXISTING admin menu on the backend of WordPress. Yes, the menu should exist, like Settings, Post, Page, etc or any other menu initiated by plugins or themes. We could also include a template PHP to show what we need to show when the sub-menu we inserted is currently active.

     

    function my_plugin_menu() {
        add_theme_page('My Plugin Theme', 'My Plugin', 'edit_theme_options', 'my-unique-identifier', 'my_plugin_function');
    }
    add_action('admin_menu', 'my_plugin_menu');
    
    function my_plugin_function()
    {
        echo "Hello World!";
    }

     

    Instead of echoing a string, “Hello World!”, you can also include a page-template.php or HTML BODY formatted code written in PHP file.  Now, after writing or pasting the code into your custom plugin or active theme function.php. Everything should work fine! See, Easiest way of having a site is WordPress for other helpful tips and tutorials.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic. Login here