-
Notifications
You must be signed in to change notification settings - Fork 4.7k
FSE: Template resolution for new posts and pages #32442
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
Conversation
| if ( | ||
| $post && | ||
| 'auto-draft' === $post->post_status && | ||
| current_user_can( 'edit_post', $post->ID ) |
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.
Adding a user capability check here, since it's normally run for non-public posts, when the post_status isn't provided by the query, see: https://github.com/WordPress/wordpress-develop/blob/abb27bc8daf03cebb5e39abad986177d77377416/src/wp-includes/class-wp-query.php#L3097
|
Size Change: -17 B (0%) Total Size: 1.03 MB
ℹ️ View Unchanged
|
|
This closes #27391 right? |
@youknowriad Yes, thanks for finding that issue! I've linked it to the PR. We probably want to have a separate issue to track solving some of the underlying concerns around template resolution described in that issue, e.g.
But the use of a filter in this PR gets it working with the current template resolution system. |
|
While testing this I noticed a couple related bugs that also exists in trunk I think. The "Default template" is actually the "Single Post" template there, we should probably hide the "Default template" from the list when we were able to resolve the current template. (This might be visible now because of this PR) The other bug, is that the list there should probably exclude all the hierarchy templates like "index", "404" and only show the potential custom templates for current CPT. (This might be something that needs its own issue/PR) |
youknowriad
left a comment
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.
I'd appreciate a second check from @ockham if possible.
I think the duplicated "default template" and "single post" is something that we could consider solving in the current PR.
Regardless, this looks good to me, a bit hacky but there's no way around it in the plugin. A better fix could be done in Core directly.
ockham
left a comment
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 too!

Description
Resolve the block based template when editing a new post or page.
The template resolution system makes a request like
/?page_id=1234&_wp-find-template=true, depending on WP_Query to resolve a page or post using thepage_idorp(post_id) in the query string. With new posts/pages, a placeholder post with the statusauto-draftis created. But by default WP_Query will not resolve these posts, unless the query is specifically set to look for them (the post is removed from the query output on this line: https://github.com/WordPress/wordpress-develop/blob/abb27bc8daf03cebb5e39abad986177d77377416/src/wp-includes/class-wp-query.php#L3117)Resolves #27391
How has this been tested?
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist:
*.native.jsfiles for terms that need renaming or removal).