Custom rewrite permalink doesn’t work

You need to use %cities% (matching the name of the taxonomy).

I thought that %city% was just a placeholder with a random name.

Not quite – it’s called a permalink structure (permastruct) and is used to map to a regular expression. When you call register_taxonomy, it automatically registers a new permastruct with the same name as the taxonomy.

Read up on WP_Rewrite::add_permastruct which hopefully gives a bit more insight.

Update: Let’s clarify what we’re aiming for:

  • /city/new-york/events/ – All events posts attached to new-york
  • /city/new-york/restaurants/ – All restaurants posts attached to new-york
  • /city/new-york/events/foobar/ – Single events “foobar”

And do you need hierarchical slugs for cities? i.e. england/london (answering “yes” is going to make things difficult). Or is london sufficient?

Update 2: How about?

  • /events/new-york/ – All events posts attached to new-york
  • /restaurants/new-york/ – All restaurants posts attached to new-york
  • /restaurants/new-york/foobar/ – Single events “foobar”