Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thanks for working on this, Riad. While an update will fix the issue, I'm a little worried about the
WP_Query
calls this change will produce.Since only custom templates (is_custom = true) are allowed to be page/post templates, maybe we use that property and conditionally add templates to the list?
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'm not sure I understand? Are you worried about the number of requests? Is there a way maybe to solve this by adding a new
is_custom
to the query object?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.
Yes, I'm worried about the number of requests.
We'll still need the
post_type
to check if the template is supported for this specific post type.I think this has to be done slightly differently than we do in a plugin. I can create PR for my idea of PoC later today/tomorrow if we're not limited in the timeline.
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.
Rough example:
We have to use properties directly in the loop instead of passing post type as query argument because we don't have access to the current post type in the
get_post_templates
method.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.
Why we need that to determine whether a template is
is_custom
?--
I think we can probably commit the PR as is and consider improvements in follow-up to buy us time WDYT?
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.
Sounds good. I can do a follow-up PR for beta 3.
We don't need to know the post type for
is_custom
.