-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Swap Template: Show the right templates for the right post type #57149
Conversation
Size Change: +22 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
Flaky tests detected in 5fb36c9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7248083451
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
- In the editor where the post type is
post
, I only see the "post" specific templates in the swap template modal. - In the editor where the post type is
page
, I only see the "page" specific templates in the swap template modal. - It works the same way when I create a custom post type and define it in
customTemplates
in theme.json. - If I select any page in the Site Editor, I only see the "page" specific templates in the swap template modal.
return useSelect( | ||
( select ) => | ||
select( coreStore ).getEntityRecords( 'postType', 'wp_template', { | ||
per_page: -1, | ||
post_type: 'page', | ||
post_type: postType, | ||
} ), | ||
[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to add postType
to avoid an eslint warning error regarding a dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! We should add the postType
in deps though as @t-hamano suggests.
closes #57112
What?
We recently moved the template swapping modal to the post editor, this highlighted a small issue where the list of available templates was hardcoding the templates that are available for the page post type. This PR fixes that by using the right post type to fetch the available templates.
Testing Instructions
1- Edit a post in 2024 theme, you should only see the "post" specific templates in the swap template modal.
2- For pages, you should only see "page" specific templates.