Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom post types in navigation editor #34440

Closed
spacedmonkey opened this issue Sep 1, 2021 · 4 comments
Closed

Add support for custom post types in navigation editor #34440

spacedmonkey opened this issue Sep 1, 2021 · 4 comments
Labels
[Block] Navigation Link Affects the Navigation Link Block [Block] Navigation Affects the Navigation Block

Comments

@spacedmonkey
Copy link
Member

spacedmonkey commented Sep 1, 2021

What problem does this address?

The current menu screen, allows for custom post types to be added to menu. This includes both custom post type posts and archives. See screenshot from current editor.

Screenshot 2021-09-01 at 10 28 48

However these custom post types are not reflected in navigation editor.

Screenshot 2021-09-01 at 10 31 30

What is your proposed solution?

Add support for custom post types in navigation editor

@talldan
Copy link
Contributor

talldan commented Sep 21, 2021

This is supposed to be supported, but it does seem like a bug has crept into the navigation block.

I registered a custom 'Books' post type, and this is what I see in the inserter:
Screenshot 2021-09-21 at 5 16 45 pm

There are two Post Link block variations! I'm pretty sure the second one is supposed to be Books.

@talldan talldan added [Block] Navigation Affects the Navigation Block [Type] Regression Related to a regression in the latest release labels Sep 21, 2021
@talldan
Copy link
Contributor

talldan commented Sep 21, 2021

Did some more digging, and I've changed my mind, I don't think this is a regression, but just a shortcoming of how the block variation's title is handled:

if ( property_exists( $entity->labels, 'item_link' ) ) {
$title = $entity->labels->item_link;
}
if ( property_exists( $entity->labels, 'item_link_description' ) ) {
$description = $entity->labels->item_link_description;
}

A lot of variations probably won't have an item_link property, but from what I recall the custom post type's labels are merged with the base labels object for a Post, which is why 'Post Link' is shown. I think it should probably fallback to singular_name or name, but it'll be tricky to detect the absence of an item_link.

@talldan talldan removed the [Type] Regression Related to a regression in the latest release label Sep 21, 2021
@spacedmonkey
Copy link
Member Author

@talldan How does this work, if show_in_rest is false but show_in_nav_menus is true? This means that post type can be shown in menus but we can't get the data via the REST API?

Also, is there any way to use the post type's icons as the block icon?

@spacedmonkey spacedmonkey added the [Block] Navigation Link Affects the Navigation Link Block label Nov 1, 2021
@kathrynwp
Copy link

Closing this issue due to the Navigation Screen project being moved to an inactive status on the feature projects page in coordination with the project leads. (The developer documentation in the initial post are no longer accessible)

If this work is picked back up, issues can be revisited and reopened as needed. Thanks for pitching in on this early feature so the wider WordPress project could benefit from the lessons learned!

@kathrynwp kathrynwp closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Link Affects the Navigation Link Block [Block] Navigation Affects the Navigation Block
Projects
None yet
Development

No branches or pull requests

3 participants