Support » Plugin: Custom Content Shortcode » Nested ACF Relationship

  • Hi,

    In a CPT Archive, i try to fetch a field from related posts of a different CPT (set with ACF Relationship), which is also an ACF Relationship (related to a third CPT).

    I use this:

    [related my_acf_relationship_to_2nd_cpt]
        [field my_acf_relationship_to_3rd_cpt], 
    [/related]
    

    This works, kind of, by returning the final posts IDs.
    But i need to get these posts titles: it would require to nest another CCS [related], which doesn’t work…

    I tried the out parameter with no luck:

        [field my_acf_relationship_to_3rd_cpt out=slug], 
    

    Any idea how to proceed please?

    Sorry, it’s a bit tricky to explain.

    • This topic was modified 8 months, 2 weeks ago by studioavanti.
    • This topic was modified 8 months, 2 weeks ago by James Huff.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Have you tried to use a Metashortcode. So you could run one [relation] within you code – pass the id of the post to the metashortcode and get back the final title from there.

    I never tried this for [related] but in other cases I was able to break some limits I had using this method.

    • This reply was modified 8 months, 2 weeks ago by polarracing.
    • This reply was modified 8 months, 2 weeks ago by polarracing.
    Thread Starter studioavanti

    (@studioavanti)

    Thanks for your suggestion, it gave me the occasion to use this Meta shortcode i’ve never used before.

    I tried a few things like nesting a second [related] in the meta shortcode or looping through the posts IDs fetch with [pass] inside the first [related], no luck so far.

    The [related] does not let you define the post you are searching in – just the field.

    That said I would try following approach.

    1. In the current code I would run the [related] to get the ID of the first relation.
    2. Then pass this to the meta-shortcode and run a loop there to get the right post
    3. Run related in the loop within the meta shortcode to return my result.

    • This reply was modified 8 months, 2 weeks ago by polarracing.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Nested ACF Relationship’ is closed to new replies.