• I am pretty sure that one can have custom taxonomies for “post” , “pages” or “custom-post-type”s; and one cannot create a custom taxonomy of another custom taxonomy.

    Any confirmation on this would be helpful.

    The reason is due to the weird requirement, a gist of which is as follows —

    1. There is custom post type ‘Music Piece’ (music-piece) – which is essentially a catalog entry of any performance of classical music. This has a custom-taxonomy “composition”. One “composition” can have many music-piece(s) associated. Apart from this music-piece has other taxonomies such as conductor, year, location etc.

    2. Logically the ‘composition’ should have ‘composer’, ‘period’, ‘style’ associated with it. But associating the mentioned taxonomies with the taxonomy “composition” is not possible in WP. One could associated all of these with music-piece post type, but it is not only cumbersome but also error prone.

    Any work around of the limitation of regressive taxonomies is appreciated. Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’d set it up as having ‘Composition’ as it’s own custom post type as well, and working out a relationship between that and the ‘Misuc Peice’ post type. That way you can have the taxonomies linked to the right post types and everything wtill be a fair bit easier to manage.

    The only “hard” part about that is that there’s no built-in way to have post types relatve to each other, so you’ll ahve ot sort out some custom code to do that. It’s not a hard thing ot do though. Most times that I’ve done this I’ve set up a post_meta entry for one that references the other post type.

    Moderator bcworkz

    (@bcworkz)

    You’re right that you cannot normally relate terms from two different taxonomies, except through the post object they are assigned to. However, if you want to custom code something, you could interrelate disparate terms just as catacaustic suggested relating different post types. For example, a term for “composition” taxonomy could custom relate to a “conductor” taxonomy term via a certain meta value. In the same manner, a conductor term could relate back to a composition taxonomy term if that made sense to do so.

    In many cases it would make more sense to create a hierarchical term structure than to attempt to interrelate disparate terms. This is feasible for one to many relations, but not many to many.

    Thread Starter arunagirinathar

    (@arunagirinathar)

    Thank you for the reply. Based on your inputs, I came up with this —

    create two custom post types – one for compositions, one for music pieces.
    The composition post type has the taxonomies like composer, period, style etc. associated with it.

    The music-piece has its unique taxonomies like conductor, year, location etc.

    I figured there are at least two ways to link the two post types with a common identifier – have a custom taxonomy that spanws both the post types or

    more logical have a custom-post-meta (is that the correct term ?) associated with every ‘post’ in music-piece which references the composition ID. As to how I am going to represent it in the UI is still not clear – I could have a dropdown , or an Autocomplete text box – the latter I am not very sure how to execute.

    The former seems easier (as in minimum code) and I could write a hook to copy the title+composer as the only term in the custom taxonomy (assuming that there are no duplicates).

    One more query on best practice. Should I create custom functions that link the data between the posts (transparently) – perhaps by the use of hooks in —

    a. the plugin that declared these custom post types or
    b. the theme

    (Further) Suggestions would be helpful.

    Thank you again.

    Moderator bcworkz

    (@bcworkz)

    If a theme or plugin is not subject to periodic updates, your code could reside there, but it’s better to create your own custom plugin or child theme. This is a must if there will be periodic updates, otherwise your code will get overwritten.

    A plugin is easier to create than a child theme, but utilizing custom templates from there can be a little tricky. Custom templates are better off in a child theme. Hook code can reside in either place. Some framework based themes already take up the child theme slot. You then must use a plugin if that theme is subject to updates.

    Thread Starter arunagirinathar

    (@arunagirinathar)

    @bcworkz

    Thank you for your insight. Just to clarify, everything is custom code – plugin, theme and integration with external (web-)services. There is very little that is used from the WordPress Plugin Repository – the only ones used being Yoast, and few plugins for back-office work like DB-Backup, ithemes Security that have little to no direct impact on the code.

    One new requirement is being able to use the wordpress data with React – so I guess the logic has to be done in a plugin as I do not see how a react-app can make use of a “theme” to process data.

    Thank you again (everyone).

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Taxonomy of Taxonomy’ is closed to new replies.