I specified category id as follows, but still query all posts, not posts in category 4 (term_id).
<!-- wp:query {"query":{"category":4,"perPage":0,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
<!-- wp:post-template -->
<!-- wp:post-title {"isLink":true} /-->
<!-- /wp:post-template -->
<!-- /wp:query -->
2
Answers
thx, i fix it using:
Firstly, go to visual mode in the WP block editor.
Select Query loop block in the editor
In inspector control (on the right side of text editor) select Block panel
Under Block panel, go to Filters (click the + icon)
Select
Taxonomies
option, then type the desired category nameMake sure now the query loop only shows the filtered posts
Now turn the editor mode to code editor, you will see the taxQuery like this
<!-- wp:query { ... "taxQuery":{"category":[23]}}} -->
Source from Gutenberg:
Function which build
WP_Query
arguments from the block’s JSON data:tax_query
array formation from block’s attributequery.taxQuery
:Snippet: