I'm setting up a WP-page for a client. I have a dropdown menu and the primary menu item is an unclickable link that says "MENU". On every subpage, I need the title of the subpage to display where it usually (only on the startpage) says "MENU".
I've been able to accomplish this with this code that my theme support helped me with:
(function($){
var title = '';
$('.menu-item').each(function(){
if( $(this).hasClass('current-menu-item')){
title = $(this).find('span').text();
}
});
if(title){
$("#menu-item-36 > a span").text(title);
console.log(title);
}
})(jQuery);
#menu-item-36
is the ID for the primary menu item - "MENU".
The problem is that I also need the pages to load smoothly without reloading the header on every page. So I'm using a plugin called Ajaxify Pro that works great for doing this, BUT Ajaxify removes the class 'current-menu-item' from the active menu item, so my code doesn't work any longer.
Is there a way around this? The active/current menu item in the submenu doesn't get any class different from the other items in the menu, so I'm twisting my head around a way to solve this.
Any help would be much appreciated!
Here you can see the page with Ajaxify activated and the code not working: http://test.frankochrakel.se/