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

Filter custom block templates with PHP #2031

Closed

Conversation

Mamaduka
Copy link
Member

@Mamaduka Mamaduka commented Dec 8, 2021

Follow-up for #2020.

This method calls get_block_templates once and uses block template properties directly for filtering. This way, we can avoid hitting the database for each public post type.

The previous method is useful when we already know the current post type we request templates for, like when using REST API.

Trac ticket: https://core.trac.wordpress.org/ticket/54335


Cc @youknowriad @noisysocks @hellofromtonya

foreach ( $block_templates as $block_template ) {
if ( ! $block_template->is_custom ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel maybe this should be internal to get_block_templates (an argument of the query) but I'm fine with this approach as well.

@noisysocks
Copy link
Member

@noisysocks noisysocks closed this Dec 14, 2021
@Mamaduka Mamaduka deleted the core/2020-block-template-follow-up branch April 7, 2022 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants