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

1 Answer 1

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 ?

7
  • 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.
    – user59172
    Feb 16, 2015 at 19:31
  • That plugin seems to be free, why are you not using it if it could solve your problem ? Feb 16, 2015 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.
    – user59172
    Feb 16, 2015 at 19:51
  • jancbeck.com/articles/…
    – user59172
    Feb 16, 2015 at 20:01
  • I've updated my answer. Feb 16, 2015 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.