WordPress FAQ

How to Use WP_Query in WordPress

Developers must ensure show_in_rest is set to true in their custom post type registration to allow the Query Loop block to access data. medium confidence based on 8 community reports

Developers must ensure show_in_rest is set to true in their custom post type registration to allow the Query Loop block to access data.

Based on 8 community reports.

Linked sources: 8.

Known Issues

Community Q&A

How do I use WP_Query in WordPress?

You use WP_Query by creating a new instance of the class with your arguments array to fetch posts, then loop through them using have_posts() and the_post().

Why is my custom post type not showing in the Query Loop block?

This is usually because ‘show_in_rest’ is set to false in your register_post_type function; Gutenberg requires the REST API to populate the dropdown.

Is WP_Query safe for large databases?

Complex queries can cause resource exhaustion; it is recommended to limit search query lengths and use caching or specialized search plugins like Relevanssi.

Reddit Sources