- This topic has 11 replies, 3 voices, and was last updated 2 years, 12 months ago by
Fernando.
-
AuthorPosts
-
March 20, 2023 at 12:44 pm #2574688
Jens
Dear Generatepress team,
I am trying to use the GB Query Loop to show featured image, title and excerpt from custom post type (education) that is linked via an ACF relationship field in another custom post type (jobs) one each job’s single.
I have tried to use https://generatepress.com/forums/topic/acf-relational-field-output-via-generateblocks-dynamic-data/. Can you give me some more information how to get this to work.
Thanks in advance.
March 20, 2023 at 5:52 pm #2574835Fernando Customer Support
Hi Jens,
Make sure
my-class-nameis added as a class to the Grid Block of the Query Loop Block.Adding Custom Classes: https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/
Then replace
my_relationship_fieldin the code with the slug name of your Relational Field.#2 in the instructions by David is adding a PHP Snippet. Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
March 21, 2023 at 12:18 am #2575071Jens
Hi Fernando, thanks for the quick reply. I have checked the implementation again. Unfortunately it is not working according to the instructions.
It would be great if you could have a look. You find more info in the private information. Many thanks in advance!
March 21, 2023 at 12:29 am #2575083Fernando Customer Support
Can you try placing the Relationship field outside the Group field?
March 21, 2023 at 1:14 am #2575140Jens
Thanks for the tip. I have placed it outside the group field. Now the field is also directly show in the dropdown options of “Post Meta Field”. But it still does not show anything on the single.
March 21, 2023 at 3:32 am #2575314David
StaffCustomer SupportHi there,
in the code snippet, immediately after this line:
$relationship = get_field( $relation, $queried_object );Can you add:
var_dump($relationship);This will dump that variables value to the page, so we can then see what is inside it.
March 21, 2023 at 3:48 am #2575338Jens
Thanks! Done.
March 21, 2023 at 4:43 am #2575414David
StaffCustomer SupportSo thats nothing then 🙂
Try changing this line:
$relationship = get_field( $relation, $queried_object );to:
$relationship = get_field( $relation );March 21, 2023 at 2:01 pm #2576131Jens
Thanks for the effort so far! Unfortunately that did not do the trick. Do you have any further ideas? Thanks in advance.
March 21, 2023 at 5:44 pm #2576232Fernando Customer Support
Hi Jens,
To test, can you try creating a new Relationship field, and test the code on this new one?
Make sure to set a value for it on the CPT you’re testing.
March 21, 2023 at 11:29 pm #2576380Jens
Hi Fernando, that also does not work. I will reach out to a developer to have a deeper look. Thanks for your support.
March 21, 2023 at 11:39 pm #2576388Fernando Customer Support
I see. You’re welcome, Jens!
-
AuthorPosts
- You must be logged in to reply to this topic.