Automattic / Co-Authors-Plus

Multiple bylines and Guest Authors for WordPress
https://wordpress.org/plugins/co-authors-plus/
GNU General Public License v2.0
290 stars 205 forks source link

Bug: Adding CAP guest authors to navigation menu produces incorrect link #904

Closed gamebits closed 1 year ago

gamebits commented 1 year ago

When editing nav menus, there’s an option to add Guest Authors. guest-authors

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.

oscarssanchez commented 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)

leogermani commented 1 year ago

@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