How can I select a primary category?

I’m looking for a plugin or suggestion on how to select a primary/main (custom taxonomy) term in a custom post type.

For example, I’m developing a WordPress website for Musicians. I have a custom post type named “Releases”, in “Releases”, the user enters the information about a song (title, links, etc) and then selects an artist (or multiple artists) from the “Artists” taxonomy.

My goal is to output something like “Bob Dylan ft. The Band…” using something like get_the_terms();

I’ve already thought of having the user manually enter the primary artist (or secondary artists) I even thought of creating an duplicate taxonomy called (Primary Artist/Secondary)… Both of these solutions seem a bit redundant. Is their a plugin that would allow me to just keep it all in one taxonomy, having the user just select which artist is the primary?

2 Answers
2

There is no concept of “primary” term in WordPress. Taxonomies are grouping mechanism. Post belongs to multiple terms on equal terms (no pun intended). No term is “more” of a group than the rest.

From brief description of your use case, intuitively Artists would be much better defined as CPT too. But then it comes down to relationship between posts and WP doesn’t do this either out of the box. Though there are staple plugins like Posts2Posts for it.

Overall I would recommend to put a bit more thought in architecture. When taxonomies are getting too elaborate it tends to be a bad sign for long term.

Leave a Comment