I'm building this website for a record label; they have both individuals and groups (bands) as artists. I have a CPT for Artists (both kinds). I have another CPT for Groups and a relationship connecting each Groups post to the Artists posts of the individual members of the group. In the Artists CPT I have a radio button field to indicate whether a particular artist is an individual or a group.
Using a conditional to test that radio button field, when its value is 'Group' I want to display a View of the (individual) Artists that are related via the Groups post. Pretty confusing, isn't it... and I haven't been able to wrap my brain around how to accomplish this. Any help is greatly appreciated!
Hi,
Thank you for contacting us and I'd be happy to assist.
The structure that you're following makes sense however, I'm not sure if you need the field to check whether an artist is an individual or part of a group. A single artist can be part of a group and still be working on individual labels.
To make it simple, you'll need two CPTs:
1. Artists
2. Groups
These two post types can be connected using a many-to-many relationship "Groups <-> Artists".
( note: I'm suggesting a many-to-many relationship because one group can have multiple artists and one artist can also be a part of multiple groups )
With this structure, you'll be able to use the post view with relationship query filter to show:
a). which group(s) an artist belongs to on the single artist post
b). all the artists that belong to a group on the single group post
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Hi Waqar - I'm sorry if I wasn't clearer in my original message. The two CPTs and the relationship already exist. What I am having difficulty with is creating a View within the Content Template for an Artist that happens to be a Group that shows the individual Artists in that Group...
The site is in development, fully backed up daily, and I'm happy to give you access if that helps you see the current situation.
Thanks for the update and it's good that your post types and the relationship between them are already in place.
Your next reply will be private so that you can share the temporary admin login details.
I'll be in a better position to guide you with the next steps accordingly.
Thank you for sharing these details.
To show all the artists who are members of the related group(s) of the current artist, you can follow these steps:
1. You'll need 2 nested views. The first parent view that gets the current artist's group, and the second child view (inside the first) that shows all the artists related to the current group in the parent view's loop.
Note: Since nesting of views is not supported in the blocks-based views, you'll have to use the classic views editor for both these views.
2. The parent view, let's call it "View to get current artist's groups", will be set to show the "Groups" posts, with a relationship query filter to show only the results related to the post where this view is shown.
3. The child view, let's call it "View to show the artists of current group", will be set to show the "Artists" posts, with a relationship query filter to show only the results related to the current post (group) in the loop.
4. Once these two views are ready, you can place the shortcode of the child view in the loop of the parent view and then the shortcode of the parent view in the template "Template for Artists".
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view )
Let me know if any step/point is not clear.
Thank you, Waqar - your steps are clear and easy to understand. However, while I was able to set up the child View as in step 3, I ran into difficulty with setting up the View in step 2. As you can see in the "selecting-the-relationship" screenshot, besides 'any relationship', two other selections are shown - "in the Groups Artists relationship" and "in the Group relationship". The first exists and is the one I try to select; the second doesn't even exist! (See the "relationships" screenshot.) And after I click the Save button after selecting "in the Group Artists relationship", no filter is shown (see "selection-doesnt-display" screenshot), although it _does_ display when the window is refreshed. In any case, it doesn't work - when checking the result by viewing a Group's Artist post, "No items found" is displayed. Perhaps there's a clue of some sort in the fact that in the Loop Editor I have changed the wpv-no-items-found message to "No Group found", but that's not what's getting displayed.
Thanks for the update.
I checked both your views and they were set up correctly.
The only missing piece was that in the view "Group Artist's Artists" the "The current post in the loop" option needed to be selected (instead of "The post where this View is shown" ) in the post-relationship query filter.
( screenshot: versteckter Link )
I've made this change and it is working now.
( screenshot from {yourwebsite.com}/artist/idle-hands/ - versteckter Link )
Nested Views are tricky, but thanks to Waqar's patient and thorough help, my issue is resolved now. Thank you for the excellent tools and support!