Title: Blocks &amp; WP_QUERY
Last modified: July 1, 2020

---

# Blocks & WP_QUERY

 *  [elboz](https://wordpress.org/support/users/elboz/)
 * (@elboz)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/blocks-wp_query/)
 * Hello,
    I have a general question on how to use WP_Query with blocks attributes.
   I will create one block with many values to replace my metabox: – Custom post
   ID, – Taxonomies – text
 * I would like to know how to use wp_query to search on those values? I do not 
   find any information very clear on that. Do I have to keep the metabox and add
   it to a bock or can I completely switch to the block and adjust my query? but
   in this case which object I have to use on the WP_Query?
 * Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/blocks-wp_query/#post-13059509)
 * 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](https://wordpress.org/support/users/elboz/)
 * (@elboz)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/blocks-wp_query/#post-13059794)
 * 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
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/blocks-wp_query/#post-13064504)
 * 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.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Blocks & WP_QUERY’ is closed to new replies.

## Tags

 * [block](https://wordpress.org/support/topic-tag/block/)
 * [metabox](https://wordpress.org/support/topic-tag/metabox/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/blocks-wp_query/#post-13064504)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
