Skip Navigation

[Resolved] In a view of a repeatable field group, output the post URL of the “parent” post

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a View that shows a repeatable field group (RFG). In the View, I would like to display the URL of the parent post.

Solution: It's like displaying information from a related post. Use the "item" attribute and the .parent syntax to display information from the parent post. The slug of the relationship is identical to the slug of this RFG.

[wpv-post-url item="@your-rfg-slug.parent"]
This support ticket is created 5 years, 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 5 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1334277

Hi there,

I have two custom post types named Artist and Artwork. There is a one-to-many relationship between them.

The Artwork post type has a repeatable field group (image, caption, year, medium, dimensions), allowing me to associate multiple images with a single Artwork.

On the Artist page, I have a visual grid of the first image of the repeatable field group of all Artwork posts connected to the Artist. To make this magic happen, I created a View (4-column grid of artwork) and inside it placed another View (first item in repeatable field group).

In the "nested" view (first item in repeatable field group), I want to be able to output the post URL of the Artwork post. Is there a way to do this?

Thank you!

Saul

#1334473

Hi, yes you can display the URL of a related post inside a View. RFGs are technically implemented like child posts in a one-to-many relationship with their parent post. The syntax for the shortcode looks like this:

[wpv-post-url item="@your-rfg-slug.parent"]

You would replace your-rfg-slug with the slug of your RFG, and insert this shortcode in the Loop or Loop template of your RFG View. Let me know if you have questions about that.

#1335949

This worked perfectly! Thanks, Christian!

By the way, is there any documentation on the Toolset site about using the PHP API with repeatable field groups?

Thanks again!

Saul

#1335961

Nothing specific to RFGs, but you can use the Post Relationships API to determine the parent post of a specific RFG or to get a list of RFGs attached to some specific parent post. The toolset_get_related_posts API is ideal for this: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
The post relationship slug for an RFG relationship is the same as the RFG slug. If you have questions about that API implementation, feel free to create a new ticket so we can discuss in detail.