Home Forums Add-ons Flexible Content Field using a layout twice Reply To: using a layout twice

  • Thank you for responding.

    I contacted support with a ticket originally and they said it wasnt possible….

    So I concocted this crap.

    Now I see that they are wrong and it is possible.
    My issue was one of my layouts had a relationship field.
    I wanted to get the relationship ID’s.
    So I used
    get_sub_field('relationship_field', false)

    This does get the ID’s only but breaks the_row and stops the rest of sections outputting.

    I got the Id’s a different way (got the whole object and then used $object->ID)

    As for the file exists voodoo:

    get_template_part doesnt keep variables so if you make something like this:

    $var = 5;

    You cant use $var inside that template.
    So it’s kinda stupid.

    This allows you to get a template part without losing your variables, or needing to use global.
    It also uses locate_template which gets the right template if there is a child theme.
    Works nicely 🙂