0
votes

What I want to do is quite simple and I think it is a standard functionality of WordPress, it worked for a long time but now it's broken.

Let's say I create a new page called 'Contact' and add this page to an existing menu, the menu title will appear as 'Contact'.

After that I'll edit the page and change the page title to 'Contact us'. I expect the menu title to be 'Contact us' now but it's still 'Contact'.

I know that I can change the menu title manually (Appearance > Menus) but I want it to be changed automatically.

The menu gets registered in the functions.php of the theme:

register_nav_menus(array(
  'main-navigation' => __('Main navigation')
));

There have been changes in the code of the theme but none of them should have an impact on the menus. I installed the plugin 'WooCommerce' a few days ago, perhaps this has an influence on the menus?

EDIT: I've found out that it only affects existing pages, which have a hyphen in its title. But why?!

1

1 Answers

0
votes

It seems like WordPress converts the hyphen character to the dash character automatically. I created a new page with the following page title:

Foo - Bar

However, when I checked the menu title (Appearance > Menus), I found the title was displayed as:

Foo – Bar

The page gets stored in the database with a customized menu title (page title with a hyphen and menu title with a dash) and that's why the menu title doesn't get updated if I change the page title.

Ugh!