I have an audio website and I want to allow users to make custom playlists from posts.
I am using posts as Albums which contains the Tracks. I thought of creating a custom post type and using it to hold a user select playlist based on the default posts.
Is this a good idea or is there a better way to allow users to create custom playlist.
Notes:
- I had a look at this tutorial. It is what I’m looking for but for individual tracks in the post.
- The audio is stored in arrays in custom fields, i.e
custom_audio{ audio=>"name", url=>"www.text.com"}
What you are looking for is to create a relationship between a Custom Post Type and the Post type.
If your users have editing capability for the CPT, then yes, it’s a good idea to use the CPT’s to hold the information about the Albums (normal posts).
The easiest/fastest solution is to use a plugin.
Posts to Posts is meant exclusively for this (my emphasis):
And another one is Advanced Custom Fields. As I’m a regular user, I can illustrate its use for this case.
Create a Field Group with the following configuration:
click to enlarge
That results in this:
The result snapshot have a little trick though. The normal box that ACF generates has a very short height.
To modify the box height, use the following code in your theme’s
functions.php
file, or a custom plugin which makes this theme independent.Finally, read the plugin’s documentation to see how to grab the
album_posts
field value and play that funky music 🙂