Bump. Surely there’s a way to do this?
Found a solution! It requires access to the following PHP functions:
http://php.net/manual/en/function.parse-url.php
http://www.php.net/manual/en/function.http-build-url.php
…as well as the DOMDocument object.
Once you have that, add a filter for ‘wp_nav_menu_items’ with the following:
function makeDeeplinks($items,$args = null)
{
$dom = new DOMDocument();
$dom->loadHTML($items);
$linkNodes = $dom->getElementsByTagName('a');
$count = $linkNodes->length;
for($i = 0;$i < $count;$i++)
{
$node = $linkNodes->item($i);
$url = parse_url($node->getAttribute('href'));
$url['fragment'] = $url['path'];
$url['path'] = '';
$node->setAttribute('href',http_build_url(null,$url));
}
return $dom->saveHTML();
}
It basically takes the menu items string, converts it into a DOM object, pulls all the ‘a’ tags and turns the path into an anchor reference.