Closed gamebits closed 1 year ago
I dug a bit on this. This seems to be because of post meta used to build the nav menu links. It is using the gui
field from the author post to create that meta. In order to change it I think one "quick" way to solve is we could set the rewrite rule to use slug => 'author'
, however, I think that could mess with the author permalinks in general (untested).
Another solution could be to manipulate the gui field on save_post
to resemble the correct structure. The cons that i see with that solution is possible conflicts with user and guest authors creation. For example, I see that you can create a guest author with unique slug, and you can create a new user that would end with the same permalink structure as the guest author (you can't do the opposite though, which is good)
@oscarssanchez Thanks for looking at this.
It was easier to just filter the menu Walker when it outputs the menu items.
The cons that i see with that solution is possible conflicts with user and guest authors creation. For example, I see that you can create a guest author with unique slug, and you can create a new user that would end with the same permalink structure as the guest author (you can't do the opposite though, which is good)
Yes, conflicts between guest authors and authors (slugs and IDs) can happen but go beyond the scope of the menus. I think this solution is fine
When editing nav menus, there’s an option to add Guest Authors.![guest-authors](https://user-images.githubusercontent.com/12199101/207701028-6f700ff7-ada3-4790-8a48-8b812b781f88.png)
However, the author archive link that gets added to the menu is a 404 — for example, it uses
https://example.com/?post_type=guest-author&p=234717
instead of
https://example.com/author/joe-smith/
In this example,
234717
is the post ID for Joe Smith, but URL based on that ID doesn’t work; it needs to be the slug.