WordPress FAQ

How to Use WP_Query in WordPress

Using WP_Query requires proper REST API configuration and ensuring show_in_rest is enabled for custom post types to appear in block editors. medium confidence based on 8 community reports

Using WP_Query requires proper REST API configuration and ensuring show_in_rest is enabled for custom post types to appear in block editors.

Based on 8 community reports.

Linked sources: 8.

Known Issues

Community Q&A

How do I use WP_Query to fetch custom post types?

You must define your custom post type with ‘show_in_rest’ => true in your registration code to ensure it is accessible to the block editor.

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

It is likely because the ‘show_in_rest’ argument is missing in your register_post_type function, which prevents Gutenberg from querying the data.

Reddit Sources