Question

I'm trying to build a site at the moment that includes the different stores and times that albums will release.

I'm not sure how I should structure it with custom taxonomies and custom fields etc. The main problem is that I want each taxonomy to have the same fields but different values for each post.

I'm thinking:

Post = An Album Release Stores = Custom Taxonomy (includes Amazon, Discogs, iTunes, Tidal etc)

Album X might be available at two stores but each would have a different release time and price.

Example

Post - Album X Stores - Amazon (released 12pm, price 9.99), iTunes (released 9am, price 7.99)

Ideally I want to be able to create a post for Album X and have a table/box at the bottom of the edit page which would have a drop down to select first store, then a few customisable fields for that store on that post only. Then another drop down for store 2 and store 3 etc.

I hope I've explained this OK.

What is the best way to structure something like this and what I should use such as plugins etc that can provide this functionality?

Was it helpful?

Solution

I would implement this as such:

Album is a Custom Post Type (CPT). Release date, stores, and store details are post meta-data for the Album CPT.

Meta-data can be structured, so one option would be to store all of an album's store data as an array of associative arrays similar to the following:

// You would build this array from user-entered data collected from a form in a metabox
$album_stores = [
  [
    "name" => "Amazon",
    "url" => "https://amazon.com/album-name",
    "price_usd" => "23.95"
  ],
  [
    "name" => "Google Play",
    "url" => "https://play.google.com/music/album-name",
    "price_usd" => "22.50"
  ]
]

update_post_meta( $post->ID, "album_stores", $album_stores );
update_post_meta( $post->ID, "album_release_date", $release_date );

If you would like to be able to search or sort albums by store, a store custom taxonomy would be convenient, and could automatically be applied when an Album is published or updated based on the presence of the relevant meta-data. Otherwise, search could also be implemented by modifying or creating search queries to query Album CPT meta-data (this would also allow you to search based on store details like price, or some such).

Register a custom meta-box to the Album CPT in order to provide the user interface for editing the store and release date meta-data.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top