[英]Exclude posts by ID in a custom query built with ACF Gutenberg blocks
I have a ACF Gutenberg block with several options我有一个 ACF Gutenberg 块,有几个选项
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.如果我在一个页面上多次添加此块,并选择 select 我想要的帖子,我不希望此块中的帖子也显示在带有最新帖子的块中。
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.我尝试
parse_blocks( $post->post_content )
,但它显示的是一个大的 object,我的块可能位于第 10 个缩进处。
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.我尝试使用 page-id 作为键将帖子的 post->ID 存储在选项数据库中,但最后一个块将覆盖存储的值。
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.我最终设法使用 parse_blocks 方法来做到这一点,只是要小心不要在列或组内添加块,因为它会弄乱你的页面 object。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.