This ended up doing the trick.
function auto_hashtag( $menu_item ) {
if ( ! is_admin() && $menu_item->post_parent > 0) {
// url
$url = $menu_item->url;
$menu_item->url = preg_replace('!/([^/]+)/$!', "/#\\1", $url);
}
return $menu_item;
}
add_filter( 'wp_setup_nav_menu_item', 'auto_hashtag' );
Related Posts:
- How to add a Custom Link to a Menu with a URL that is relative to the blog URL
- WP Nav menu append to url
- wp_nav_menu including Skype URL
- Pass GET params to URL from a main menu item
- How to making dynamic URLs for menus in WordPress?
- sub menu link is not working
- Limit wp_nav_menu_objects() only to first-level menu items
- When I click a custom menu link, how do I make it update the URL in the browser to the external link?
- sub.menu’s not working
- Keep source page URL parameters on custom link menu item
- How to link current logged-in user to their author page via URL (Beginner)
- Add prefix to url, but products not showing in page SHOP
- Swap out a page that is a parent to a many many pages
- Menu links URL with PHP GET method
- Only the index.php/homepage open while other pages are not opening
- Why does WordPress convert absolute URLs to relative URLs for menu items?
- Is It Possible To A Link To The Homepage From The Admin Sidebar?
- Two pages named the same thing, on a different level but conflicting url paths in menus and direct links
- Split up wp_nav_menu with custom walker
- how to create a menu with all sub categories?
- WordPress Menu Custom Walker Class
- How to change order of menu items
- How to use a WordPress’ existing admin icon?
- Add Commas Between Menu Items?
- Allow html tags in WordPress Custom Menus Description Field
- Add custom attribute to menu item link using Filter
- Show child pages by menu order using Superfish Dropdown menu?
- Bootstrap drop down menu with wp_nav_menu
- Remove nav menu or menu item
- Adding a within ‘s from wp_nav_menu()
- Getting stripos error when trying to add menu classes
- jQuery cookie not working properly in wordpress
- Make compatible custom menu widget for Twitter Bootstrap
- Different side menu on each page
- Automatically generated menu
- Variables within wp_nav_menu
- Admin only menu/page
- wp_update_nav_menu_item not saving in multisite API
- Header style different on home and remaining pages
- wp_nav_menu_items filter :: custom menus fall outside ul class
- Schedule Page to Menu [duplicate]
- How can I add items to the menu via the PHP file?
- Limit the menu child levels under “admin > appearance > menus”
- WordPress warning: “private_to_published” Deprecated when creating nav with wp_update_nav_menu_item()
- display menus on all page except one?
- Show Menu from one WordPress install in another WordPress install
- Is this format possible with a custom Nav Walker class?
- custom walker nav issue involving ajax
- How to add html attributes to the “ul” html tag with “wp_nav_menu” function?
- Conditional menu display
- Give child-categories same class (the parent category-slug) as parent in menu list?
- How Do I Add Images To Main Navigation Menu
- Wrap list parent in div with wp_nav_menu menu
- How to add a element with walker menu right after begin of the navigation tags?
- Custom Menu not functioning properly
- Using front-page.php need new blog page
- Is it still not possible to show separate submenu with “Custom Menu”?
- Three menus – parent / child / sibling
- WordPress Nav Walker – Top menu link with dropdown link not clickable (dropdown opens)
- Rename the label on a menu location which is already defined?
- Increase wordpress menu Depth
- swap out only main menu for logged in users
- Menu Not Showing on Mobile
- How to customize the built in menu in wordpress?
- Adding CSS-class to WordPress Menu in backend
- How to open a lightbox form from a navigation menu item
- How do I remove this menu bar?
- Hide custom menu when when no menu selected
- Auto delete menu items with zero products (woocommerce)
- Why is my navigation in my onepage not working?
- Admin menu in different languages
- Navigation item – current date in url
- Edited one page in my working menu and now all menu buttons don’t open unless I right-click and open in new tab
- Need help with Walker_Nav_Menu class
- Impossible to remove page from menu
- why are my walker menu is showing like this?
- Bootstrap Theme Migrated to WordPress
- Menu with sub-items but without link
- Creating navigation out of specific IDs and their children?
- I can´t make the menu unclickable in an easy way
- Add active class to wp_nav_menu
- How to get all the menu listed in Menus Created inside the Apperance Menu?
- how to configure this type of menu
- Migrate WP Menu between sites
- Can’t change link for navigation item
- How to style wp_nav_menu?
- How to inject HTML to secondary menu on front end?
- Show Child of Parent Page including all other parents
- Show only second level menu items? [duplicate]
- Add item ONLY to the primairy navigation
- wp_nav_menu in 3.7 add name class nav navbar-nav
- WordPress Navigation default output
- Is there a limit to number of pages displayed for selection in custom menu?
- Add monthly archives menu and submenu
- wp nav menu – highlighting current page not working properly [closed]
- Hamburger Navigation Menu
- What is the best way to incorporate responsive dropdown navigation menu into custom theme?
- Submenu items not working anymore
- Icon not shown in Dropdown menus in Twenty Seventeen Theme
- How to change WP menu item type?