Support

Account

Home Forums Front-end Issues How to display selected relationship options for post type?

Unread

How to display selected relationship options for post type?

  • Hi all

    I’m having issues trying to get a list of (selected) options used for a custom post type. I can’t even get a full list let alone a selected list!

    I’ve got a relationship called author_team_members, this is made up of two custom post types (team and board). This is displayed on another custom post type called insights. The backend works great.

    My issue is on the front end. I’ve tried the following to get a list of options from author_team_members:

    $authorsMembersAll  = the_field( 'author_team_members' );
    
    $authorsMembersAll  = get_field( 'author_team_members' );
    
    $authorsMembersAll  = get_field( 'author_team_members', 'option' );
    
    $authorsMembersAll  = get_field( 'author_team_members', 'options' );
    
    $authorsMembersAll  = get_fields( 'author_team_members' );
    
    $authorsMembersAll  = get_sub_field( 'author_team_members' );

    But none of these are returning anything. The only thing I can get a return value on is:

    $authorsMembersAll = get_field_object( 'author_team_members' );

    Which is returning the following array:

    Array
    (
        [ID] => 865
        [key] => field_5bfde38fa8df0
        [label] => Author
        [name] => author_team_members
        [prefix] => acf
        [type] => relationship
        [value] => 
        [menu_order] => 0
        [instructions] => 
        [required] => 0
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => 864
        [wrapper] => Array
            (
                [width] => 
                [class] => 
                [id] => 
            )
    
        [_name] => author_team_members
        [_prepare] => 0
        [_valid] => 1
        [post_type] => Array
            (
                [0] => team
                [1] => board
            )
    
        [taxonomy] => 
        [filters] => Array
            (
                [0] => search
            )
    
        [elements] => 
        [min] => 
        [max] => 
        [return_format] => object
    )

    I’ve attached a screenshot of the settings in the backend. Any help would be great!! I’ve never used this plugin before (and this is my second wordpress site, so please bare with me) 🙂

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.