Site logo

[Resolved] Show content from ACF relationship field

Home Forums Support [Resolved] Show content from ACF relationship field

Home Forums Support Show content from ACF relationship field

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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.

    #2574835
    Fernando
    Customer Support

    Hi Jens,

    Make sure my-class-name is 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_field in 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

    #2575071
    Jens

    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!

    #2575083
    Fernando
    Customer Support

    Can you try placing the Relationship field outside the Group field?

    #2575140
    Jens

    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.

    #2575314
    David
    Staff
    Customer Support

    Hi 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.

    #2575338
    Jens

    Thanks! Done.

    #2575414
    David
    Staff
    Customer Support

    So thats nothing then 🙂

    Try changing this line:

    $relationship = get_field( $relation, $queried_object );

    to:

    $relationship = get_field( $relation );

    #2576131
    Jens

    Thanks for the effort so far! Unfortunately that did not do the trick. Do you have any further ideas? Thanks in advance.

    #2576232
    Fernando
    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.

    #2576380
    Jens

    Hi Fernando, that also does not work. I will reach out to a developer to have a deeper look. Thanks for your support.

    #2576388
    Fernando
    Customer Support

    I see. You’re welcome, Jens!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.