Skip Navigation

[Resolved] Retrieve Custom Field from a CPT Relationship outside of the Repeater Field Grp

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#1958965

Hi there,

This is a continuation from the final post in the previous thread at: https://toolset.com/forums/topic/display-a-relationship-connected-repeater-field-group-from-another-cpt/

Summary: I have two CPTs in a relationship, and I am looking to retrieve metadata from the main CPT (parent?) This was successfully achieved (Thanks, Shane!) but I am running into a small issue where because it is a _nested View_ and I am filtering it based off the "Current Post in the Loop", the Item attribute that I would use to "break out" of the Repeater Field Group to pull back the Custom Field on that CPT does not work.

[types field="unit-of-time-base-duration" item="$current_page"][/types]

I have tried to change the attribute value to $parent, @widget-faq.parent, @widget-faq.child, etc. But have not been able to successfully access the Custom Field of the relationship-link CPT.

The link to show you some details and what I've tried: hidden link

Please let me know if you have any questions. Thank you!

#1962275

Hi,

Thank you for sharing these details and the correct usage of the item attribute, in this case, would be item="@sw-deal-tiers.parent":
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/ )


[types field="unit-of-time-base-duration" item="@sw-deal-tiers.parent"][/types]

This shortcode video shows how you can select the correct source for the post-selection when using the "Fields and Views" interface: hidden link

regards,
Waqar

#1962399

Hi Waqar,

Took a look at the View and it looks like the item attribute was set correctly, but the field was still not pulling back correctly. 🙂

Shown here: hidden link

#1962513

Thanks for writing back.

In my last reply, I just wanted to show you the correct usage of the item attribute in this case and as an example only updated it in one view "Field - Deal Price ⟩ Tier 2 from Software CPT (relative to Local Loop)" (ID: 231).

If you'll go and check the view "Field - List Price ⟩ Tier 2 from Software CPT (relative to Local Loop)" (ID: 247), which is responsible for showing the List Price, you'll see that item="$current_page" is still being used in there.

You can update the item attribute there and then it will show correctly.

One thing that I'll recommend though is that you don't need two separate views to show the Deal Price and List Price in this case since they both are set to show the data from the same target post. You could have used the same view to show the shortcodes for both these fields, and any other fields from the same post.

#1963375

My issue is resolved now. Thank you Waqar for such wonderful support!