Skip Navigation

[Resolved] Display Albums and Songs inside “Artist” Post type

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

Problem:

How to display the different Albums WITH their songs in the Artist content template?

Solution:

You can try nested view, for example:

https://toolset.com/forums/topic/display-albums-and-songs-inside-artist-post-type/#post-2141609

Relevant Documentation:

https://toolset.com/course-lesson/displaying-related-posts/

This support ticket is created 3 years, 3 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by dmfzw 3 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#2138117

Hi,

I tried searching for this solution but can't find one, hopefully someone can help me out.

I have a music website in development and I need to display the albums and songs of each artist that I have on the website, with the Songs appearing on their respective Artists posts.

So far I've created an "Artist" post type, which inlcudes the name, image and bio of the artist and also a second post type called "Songs" which is the list of songs from each artist.

The songs are attributed to their respective artist by using the "post relationship" between Artists and Songs post types.

However, I want to better organize the site by placing these songs into "Albums", which in turn would display inside their respective "Artists".

I'm thinking this could somehow be achieved by creating a taxonomy for "Albums", which would just be the name of the Album, so that each "Song" would be associated with its respective "Album" taxonomy. However, I'm not sure if this is the correct method for what I'm trying to achieve or how I would then display the Albums grouped with their respective songs inside the "Artists" post types.

I'm also wondering whether a better method would be to instead create a third post type for "Albums", which would then have a post relationship between "Artists" and "Songs"?

Here's an example of what I want:

ARTIST A:

Album #1
Song #1 belonging to album #1
Song #2 belonging to album #1
Song #3 belonging to almbum #1
etc etc

Album #2
Song #1 belonging to album #2
Song #2 belonging to album #2
Song #3 belonging to album #2
etc etc

ARTIST B:

Album #1
Song #1 belonging to album #1
Song #2 belonging to album #1
Song #3 belonging to album #1
etc etc

Album #2
Song #1 belonging to album #2
Song #2 belonging to album #2
Song #3 belonging to album #2
etc etc

And so on...

Is there a way to achieive this?

Thanks in advance.

#2138565

Hello,

It depends on what you are going to achieve.

If you want to add custom fields into "Albums", then you can setup "Albums" as a custom post type

For example, if one artist can connect multiple Albums, and one Album can only connect only one artist, then you can setup one-to-many relationship between post types "artist" and "Albums", and setup one-to-many relationship between "Albums" and "Songs"

if one artist can connect multiple Albums, and one Album can connect multiple artists, then please try many-to-many relationships

More helps:
https://toolset.com/glossary/post-relationships/

#2141275

Thanks Luo, creating three CPTs seems to make sense and that's what I've now done using post relationships.

However, I'm struggling to work out how to display the different Albums WITH their songs in the Artist content template. I'm only able to display either the list of albums or the list of songs on the artist content template, but I want to display BOTH the albums with the related songs listed after each album in the artist pages.

Like this essentially:

ARTIST A's PAGE:

Album #1
Song #1 belonging to album #1
Song #2 belonging to album #1
Song #3 belonging to almbum #1
etc etc

Album #2
Song #1 belonging to album #2
Song #2 belonging to album #2
Song #3 belonging to album #2
etc etc

Any ideas on how to achieve this?

Thanks

#2141609

You can try nested view, for example, in the single "ARTIST" post, display below nested view:
1) Parent post view:
- query "Album" posts
- filter by post type relationship between "ARTIST" and "Album"
- In view's loop, display "Album" post information + below child post view

2) Child post view:
- Query "Song" posts
-filter by post type relationship between "Album" and "Song"
- In view's loop, display "Song" post information

More help:
https://toolset.com/course-lesson/displaying-related-posts/

#2142189

Hi Luo,

Thanks for the suggestion - I tried it and it almost worked. However, instead of the songs being listed after their related albums in the artist pages, albums are listed one after the other and separately beneath that the songs are listed one after the other.

I would like songs to be listed after each respective album so that visitors know which songs belong to which albums of that artist.

Maybe I missed something along the way which is causing this?

Do you have any suggestions, or if I privately provide you with the link would you be able to take a look?

Thanks for your continued assistance.

#2143417

Please elaborate the new question with more details:

I would like songs to be listed after each respective album so that visitors know which songs belong to which albums of that artist.

Take a screenshot for it

And I have enabled the private message box, you can provide a test site with the same problem, also point out the problem page URLs and view URLs, thanks

#2144265

Thanks for the details, I have done below modifications in your website:
1) Dashboard-> Toolset-> Settings-> General:
in section "Editing experience", enable option "Show both the legacy and Blocks interface and let me choose which to use for each item I build"

2) Dashboard-> Toolset-> Views:
Create two post views as I mentioned above:
- Parent post view:
hidden link
- Child post view:
hidden link

3) Edit the content template "Content template for Authors":
hidden link
At the top, add a view block, choose above "Parent post view"

Test it in frontend:
hidden link

I can see it works fine, please check if it is what you want.

#2145279

My issue is resolved now. Thank you Luo!