Skip Navigation

[Resolved] Reapetable group – link CPT1 to to several CPT2

This support ticket is created 5 years, 2 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)

Author
Posts
#1361945
repeatable- reference-not-allowed.png

Hello,

I am trying to create a publication form to allow users to create top of songs (as many songs as the user wants).
For this, I would like to create reapetable group wich allow user to link each song to the song page and to the artist page.

This is basically what I am trying to achieve.

SONG 1
- Song Title + link to the song post
- Artist Title + link to the artist post
- Video
- Content

SONG 2
- Song Title + link to the song post
- Artist Title + link to the artist post
- Video
- Content

(....)

Unfortunately, it seams that the reference field cannot be added in a repeatable group.
Is there any other way to achieve this goal ?

Thank you in advance,
Best regards,

#1362203

Hi, there's not a very easy way to accomplish this with RFGs, unfortunately, because of the post reference restrictions. Instead of a post reference field you could place a number field that holds the Artist post ID. The custom field can then be used to create a link to the Artist post and display the Artist post title, like this:

[wpv-post-link item="[types field='your-artist-id-field-slug' output='raw'][/types]"]

You would do something similar for the Song post ID, which can be used to create a link to the Song post and display the Song post title. This approach would be functional, but it is difficult to manage in wp-admin because the person editing the song list must know the numeric ID of the Artist and Song you want to connect to each row in the RFG. If that's not a problem, then I can help you set that up if you need assistance. However, most people don't want to have to track down IDs like this.

You could accomplish something similar, but without needing to know post IDs, using custom posts and post relationships instead of RFGs. Here's what you would do instead:
- Create a custom post type "Song List"
- Create a custom post type "List Entry"
- Create a custom post type "Artist"
- Create a custom post type "Song"
- Create a one-to-many relationship between Song Lists (parent) and List Entries (child)
- Create a many-to-many relationship between List Entries and Artists
- Create a many-to-many relationship between List Entries and Songs
- Create Video and Content custom fields on the List Entry post type.
- The User creates a Song List post.
- In the Song List post, the User creates one new List Entry post child for each item they want in the Song List.
- In each List Entry post, the User creates a related Song or connects an existing related Song.
- In each List Entry post, the User creates a related Artist or connects an existing related Artist.

Then you can create nested Views that display information about all the List Entries associated with a Song List, and inside the List Entry View you can nest other Views that show information about the related Artists and Songs. The main drawback is that you can not manage everything in one screen like you can with RFGs. You may need to edit separate posts in wp-admin to see all the information.

Let me know if you have questions about this.

#1362537

Hello Christian,

Thank you very much for your answer.
So if I understand well :

Solution 1./
It means that the user would have to find the post ID in order to link his Top to artists and song right ?
If yes, this would be too complicate for users.

Solution 2./
Ok, I already have a CPT "Artist" and a CPT "Song.
So with this solution, I could show informations and link about the Song and it's artist.
It seems like a good solution while using CRED publication form in the front End.
It basically means that for a "TOP 5 best songs" (CPT TOP) the user create 5 new List Entry post child (CPT List Entry) right ?

Question 1./ Is there a way to create a multistep form with "add a new song" or "Publish" ? Maybe with conditionnal ?
Question 2./ Will it be possible to link the Top (CPT Post) in a view of "All the post about this song" (CPT Song) ?

Thank you in advance Christian,

#1362833

Solution 1...It means that the user would have to find the post ID in order to link his Top to artists and song right ?
If yes, this would be too complicate for users.

Yes, you are correct. It is somewhat difficult, and it's probably only appropriate for small-scale sites where advanced Users maintain the site content.

It basically means that for a "TOP 5 best songs" (CPT TOP) the user create 5 new List Entry post child (CPT List Entry) right ?
Yes, you are correct. The User will create 5 new List Entry posts for the 1 Top post.

Question 1./ Is there a way to create a multistep form with "add a new song" or "Publish" ? Maybe with conditionnal ?
You can use multiple Forms and redirects to achieve something like a multistep Form. For example, let's say there is one Form that creates Top posts.
- User creates new Top post.
- User is redirected to new Top post single post page.
- On the Top post Content Template, there is a View of related List Entries. Right now, the list is empty, but there is also a Form to create a new List Entry post.
- User selects the Song and Artist, and fills in the Video and Content information, then submits the Form.
- The Top post single post page reloads, and the View of related List Entries now shows the new List Entry post that was just created.
- The Form to create a new List Entry is still visible, so the User can begin creating the next List Entry post right away.

Question 2./ Will it be possible to link the Top (CPT Post) in a view of "All the post about this song" (CPT Song) ?
Yes, you can create this with two nested Views.
- Create a View of List Entries and add a post relationship filter.
- Select the Song < - > List Entries post relationship in the filter, and configure the filter to choose List Entries related to the current Song post.
- Use the List Wizard to output a list with separators, and include the post ID in the list.
- Now create a View of Tops and add a Query Filter by post ID, set by a shortcode attribute "ids".
- Insert the View of Tops somewhere on your site and insert the View of List Entries in the ids attribute like this:

[wpv-view name="your-view-of-tops" ids="[wpv-view name='your-view-of-list-entries']"]

This is called passing arguments into Views, and it's explained in more detail here: https://toolset.com/documentation/user-guides/passing-arguments-to-views/