-
kronfink
Hi,
I’m working on a setup with two custom post types:
verkaufsobjekte(real estate objects) andaktuelles(news/updates).Each
aktuellespost has an ACF Post Object field calledzugehoriges_projektthat stores a reference to oneverkaufsobjektepost. On the single template of eachverkaufsobjektepost, I want to display only theaktuellesposts that are assigned to that specific object.**My setup:**
– GenerateBlocks Pro
– GeneratePress Pro
– ACF Pro
– Field type: Post ObjectWhat I’m trying to achieve:
On the singleverkaufsobjektetemplate, a Looper block that runs a query equivalent to:`php
new WP_Query([
‘post_type’ => ‘aktuelles’,
‘meta_query’ => [
[
‘key’ => ‘zugehoriges_projekt’,
‘value’ => get_queried_object_id(),
‘compare’ => ‘=’,
],
],
]);
`My questions:
Is there a PHP filter or hook available for the Looper block?
Is there any other recommended approach within GenerateBlocks to achieve this dynamic meta query without custom page templates?Thanks in advance!
-
George
Hello,
Are you using v1 or v2 blocks? I am asking because the filter name might be different!
-
kronfink
I am using v2 blocks.
-
I would recommend using the Relationship field instead of the post object.
You do not need to use custom code; with GB Pro and v2 query block, you can set the query type to post meta > relationship field name, and it will fetch the posts from the relationship field.
- You must be logged in to reply to this topic.