Support » Fixing WordPress » Create my own menu (plugin)

  • Hi,
    I would like to have my own menu on wp-admin/nav-menus.php (left part),
    who will produce my own content.
    How can I do this? Everything I found is about themes.


Viewing 11 replies - 1 through 11 (of 11 total)
  • esmi


    Forum Moderator

    I’m not a user but a developer…
    I want to create my own custom menu.
    That page is about using the existing custom menus.



    Forum Moderator

    Sorry – when you said “Everything I found is about themes”, I assumed you were not developing your own theme. See Navigation_Menus.

    Tanks but I already saw this page and it seems to be only to add the menu on the themes. Not to create one with a plugin.

    Maybe I explain it wrong, so I made a picture:

    I would like to have my own menu like here.

    So that when added it, it gives that output

    My plugin will output some html (forms, tables, …).
    So it will work on any theme.

    The answer lies within the link esmi posted. Read the documentation on the functions.

    Sorry but the answer is not in the link. :/
    I don’t want to change anything to my theme.
    Actually i’m using the Twenty Twelve theme and I don’t want to change it.

    A dirty way to do what I want, would be to
    1. create a page with a shortcode
    2. add a menu with that page as content
    But it’s definitely not an intuitive way for the user.

    Maybe I can create and add that automatically when my plugin is loaded.
    But what if the user edit or remove the page.
    Or if he want to remove the menu just for some days.

    There should be a direct way for doing this but I could not find it.

    @esmi: could you move back this topic on the “hack” place, please.
    It would be a better place.

    In fact, I’m looking for an equivalent of wp_widget for menus who will work like this:

    class My_Menu extends WP_Menu {
    	public function __construct() {
    		// menu actual processes
     	public function form( $instance ) {
    		// outputs options form on admin: nav-menus.php, left
    	public function update( $new_instance, $old_instance ) {
    		// processes menu options to be saved
    	public function menu( $args, $instance ) {
    		// outputs the content of the menu
    register_menu( 'My_Menu' );

    This would be perfect.
    But I couldn’t find something like this 🙁

    Yes, it is. register_nav_menu will add a menu you in the location you showed in your first photo, wp_nav_menu() will display the menu when you call it in your template files.

    RTFM dude.

    I read it.

    How is register_nav_menu( ); suppose to work as on my first photo: there is no way to add a function like:

    register_nav_menu(..., 'my_form');
    function my_form() {
            echo 'Option1: <input type="text" name="option">'

    I don’t get how it’s working. And they don’t speak about plugins in this link.

    Indeed, you can create a menu programmatically.

    Menu items are stored in the wp_posts table with a post_type of nav_menu_item.

    Create a menu that has some of the functionality that you want and see how it’s stored in the database. Then, figure out a way to add it in automagically. One way would be to use wp_insert_post(). Then, you can build around that functionality in your plugin.

    I excepted an easier way.
    But thanks I understand how it’s working now.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Create my own menu (plugin)’ is closed to new replies.