简体   繁体   中英

Exclude posts by ID in a custom query built with ACF Gutenberg blocks

I have a ACF Gutenberg block with several options

  • Display latest posts, lets say 5
  • Display selected posts, is a list of posts from which I can select which to show.

If I add this block several times on a page, with the option to select the posts which I want, I don't want the posts from this block to be shown also in the block with the latest posts.

How can I make the query for the block with the related posts to exclude the posts from all other blocks?

I tried parse_blocks( $post->post_content ) but it display's a big object from which my block is maybe at the 10'th indentation.

I tried to store the post->ID of the posts in the option database with the page-id as key, but the last block will overwrite the stored values.

Any ideas will be much appreciated. Thank you.

I manage eventually to do it with parse_blocks method, just be careful to don't add the blocks inside a column or a group, cause it will mess up your page object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM