Can I programmatically assign a menu position with a new menu? (2 posts)

  1. theMikeD
    Posted 3 years ago #

    1. I have support in my theme for two menus, “primary” and “secondary.”

    2. I have two menus defined: “Desktop” and “Mobile.”

    3. The “Desktop” menu is in the “primary” position. The “Mobile” menu is currently unassigned.

    What I need is either of the following, which will have the same effect:

    A. change the menu assigned to ”primary” from ”Desktop” to ”Mobile.”

    B. when the primary menu is shown, show the secondary menu instead (this implies that the “Mobile” menu is assigned to the “Secondary” position).

    Is this possible? I sure can't find anything in the codex to handle this.

    If you're curious as to why, here is why:

    The Desktop menu includes items with submenus and the submenus drop down from a trigger menu item. And in addition to the submenu items in the dropdown being clickable, the trigger item itself is clickable as well.

    So for example, the "Info" menu item:
    - when rolled over, shows the submenu
    - when clicked, shows the Info page

    All fine, except on touch devices which don't have a hover state: when touching the Info item, it registers as both a click and a hover, and so the submenu is never seen before the browser is sent to the page linked to by the Info menu item.

    "But Mike, why not just remove the click link from the menu items that have dropdown menus?"

    That may be the end game here. But if it's a simple reassignment of the menus, I'd rather do that.

    Anyone have any clues?

  2. Jesús Franco
    Posted 3 years ago #

    Interesting problem. I've searched through some WP mobile plugins but I had no luck to find something related. I wonder if checking the browser agent string is reliable, however maybe you could hack a bit using Modernizr in order to change the properties of Info page link in touch screens:


Topic Closed

This topic has been closed to new replies.

About this Topic