0

I am trying to make a custom post type called 'Songs'. It will have only two fields being 'Title' & 'Audio File'. I would also be creating a tag taxonomy field called 'Genres' so that admin can create geners on fly.

Now there are two more entities like Artists, Albums. I am lost as to how to organize my post type. It seems that every thing should be a post type but then how will i relate albums to songs and artists to albums.

Goal is to have this hierarchy

1 - Artist - (artist will have a tag of genre) 2 - Album 3 - Song

0

I think it could be a good idea to create two more hierarchical (category like) taxonomies, called Artists and Albums. This way, you'll be able to query your posts based on taxonomy / term relationships.

Basically, what I'm saying is this:

  1. Artists -> custom hierarchical taxonomy
  2. List item -> custom hierarchical taxonomy
  3. Songs -> custom post type
  4. Genres -> -> custom tag taxonomy

Please refer to this link from the Codex for a better understanding:

http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

Short example taken directly from the Codex link above, below:

$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'movie_genre',
            'field'    => 'slug',
            'terms'    => array( 'action', 'comedy' ),
        ),
        array(
            'taxonomy' => 'actor',
            'field'    => 'id',
            'terms'    => array( 103, 115, 206 ),
            'operator' => 'NOT IN',
        ),
    ),
);
$query = new WP_Query( $args );

UPDATE

How about creating two more custom post types, Artists and Albums, and having some metaboxes displayed on the Songs Custom Post Type (CPT) so that you can create a relationship between these ?

For example, in your Songs CPT, you could have a metabox or a custom field to hold the value for the Artists and for the Albums.

Does this make sense to you ?

  • But i want the user to add artist and albums with details not just name. If you can look into wpmovielibarary plugin. that has an option to create a library and movie it self is a post type. – Raheel Khan Feb 16 '15 at 19:31
  • That plugin seems to be free, why are you not using it if it could solve your problem ? – cristian.raiber Feb 16 '15 at 19:34
  • I am practicing. Taking ideas from it. But thats built on redux framework and i am not getting how the things are related to each other. – Raheel Khan Feb 16 '15 at 19:51
  • jancbeck.com/articles/… – Raheel Khan Feb 16 '15 at 20:01
  • I've updated my answer. – cristian.raiber Feb 16 '15 at 20:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.