Change type of existing menu item? (4 posts)

  1. Rulatir
    Posted 1 year ago #

    Is it somehow possible (with some hidden UI or a plugin or reasonably uncomplicated direct DB editing) to change the type of an existing nav menu item, e.g. to convert it from a "page" item to a "URL" item while keeping its database ID unchanged?

    Rationale: I am using several plugins that make it possible to store rather involved metadata in nav menu items, and I would like to avoid manually rebuilding all this metadata whenever I decide, for example, that I need to link to a specific anchor in the page instead of the page as a whole.

  2. cubecolour
    Posted 1 year ago #

    I'm not quite sure what you are trying to achieve, however Mark Jaquith's Page Links to plugin http://wordpress.org/plugins/page-links-to/ might help - which allows you to put a custom redirect in the page the menu item links to without affecting the menu.

  3. Rulatir
    Posted 1 year ago #

    I am looking for a method to change the type (e.g. "page", "category", "tag", "arbitrary URL") of an existing menu item, without having to delete and recreate it, and so that its database ID remains unchanged.

    The very specific use case is converting a "page" item that points to http://mywordpress.example.com/mypage/ to an "arbitrary URL" item that points to http://mywordpress.example.com/mypage/#myjumplink. Alternatively, is there a plugin that enables adding jumplinks to "page" menu items?

  4. cubecolour
    Posted 1 year ago #

    OK that clarifies what you're aiming for now. I'm not aware of any plugin to do this, but I think it may be possible to approach this by adding a custom attribute to the Menu Items so you can enter the name of the anchor you want to target on the page, and then use a custom walker to build the menu appending this #anchor to the URL of each menu item where this has been specified.

    There are a few tutorials that cover custom attributes and making a custom walker, but I don't think I've seen one that covers the exact functionality you require, however this one should get you started: http://www.wpexplorer.com/adding-custom-attributes-to-wordpress-menus/

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.