You cannot use WP_Query directly. Block interactivity is running client side and WP_Query runs server side. Your block can make can make REST API requests to get any data it needs from the server.
Thread Starter
elboz
(@elboz)
Thanks for your answer,
but I do not understand. When I generate my page I am on server side. So when I use wp_query to select my articles also. And it is when I generate the page that I nees to filter my articles containing blocks (I am not using ajax for research yet).
Thanks
Disregard my previous reply, I’ve misunderstood what you are asking. If you want to query for posts with certain block attributes, your only option with WP_Query is to use the text search capability (“s” query var). This can search post content for specific attribute values. If you need something more sophisticated, such as search by regexp, you’ll need to compose your own SQL query and execute it with $wpdb object methods.