WordPress.org

Ready to get started?Download WordPress

Forums

Admin Menu Editor
Non-linked Menu Item? (10 posts)

  1. brandy.brown
    Member
    Posted 11 months ago #

    Is there any way to add a menu item that is not a link? I want to be able to have menu sections with headers.

    http://wordpress.org/plugins/admin-menu-editor/

  2. Janis Elsts
    Member
    Plugin Author

    Posted 11 months ago #

    You could enter a non-existent anchor in place of the URL, like "#abcde".

  3. fmpweb
    Member
    Posted 2 months ago #

    Hi Janis

    I'm trying to achieve this too but clicking on the parent will always link to the first child. If I create a child menu item with # as the URL, then the parent becomes a dummy link that opens the submenu when hovered over as wanted.

    There is no way it seems to have a hidden submenu item which acts as a dummy. Instead, the title can be left blank but this then adds a space at the top of the submenu.

    The only way I can think how to get around this with my knowledge is perhaps CSS.

    Thanks.

  4. Janis Elsts
    Member
    Plugin Author

    Posted 2 months ago #

    I'm trying to achieve this too but clicking on the parent will always link to the first child.

    That's just how admin menus work in WordPress.

    There is no way it seems to have a hidden submenu item which acts as a dummy. Instead, the title can be left blank but this then adds a space at the top of the submenu.

    The only way I can think how to get around this with my knowledge is perhaps CSS.

    Yes, I don't think there's a way to do that with the WordPress admin menu API. You'll have to hide the item with JS or CSS.

    I suppose I could add a special "Target page: None" option to the plugin that makes an item ignore clicks, but that still wouldn't help with the hiding part. Normally WordPress will ignore hidden and inaccessible submenu items when deciding what the parent URL will be, which is not what you'd want in this case.

  5. fmpweb
    Member
    Posted 2 months ago #

    The target none idea makes sense.

    As for the hiding of the child itme, would it be possible to have a checkbox in the child item which is linked to a css rule inside the plugin, i.e. if the checkbox is checked, then that particular item will be display:none.

    Looking at developer tools the style is #adminmenu .wp-submenu li.wp-first-item a.wp-first-item

    Cheers.

  6. fmpweb
    Member
    Posted 2 months ago #

    I've noticed the CSS classes option in the parent which will help pinpoint the child css to display:none.

    Thanks.

  7. fmpweb
    Member
    Posted 2 months ago #

    Here we are - this is inline styling but you could link to a stylesheet.

    function menu_child_hide() {
      echo '<style>
    #adminmenu .menu-child-hide .wp-submenu li.wp-first-item a.wp-first-item {
    display:none !important;
    }
      </style>';
    }

    I added the .menu-child-hide class in the parent, and so it wouldn't link to it's own page, I inserted # into the URL.

    Thanks.

  8. Janis Elsts
    Member
    Plugin Author

    Posted 2 months ago #

    The target none idea makes sense.

    It's now on my to-do list and it will probably get implemented eventually.

    Here we are - this is inline styling but you could link to a stylesheet. [...]

    That works for the first item. Hiding other submenus would be more complicated since you can't change the class of a submenu item.

  9. fmpweb
    Member
    Posted 2 months ago #

    I don't suppose there's a way to include a CSS classes option in each of the children as a get around?

  10. Janis Elsts
    Member
    Plugin Author

    Posted 2 months ago #

    Unfortunately, WordPress only lets you add custom CSS classes to top level menu items. To add that option for submenus, I'd have to either set the classes via JS (somehow), or replace the entire admin menu with a custom implementation written from scratch.

Reply

You must log in to post.

About this Plugin

About this Topic