0

Hello there basically I am quite good with WP however it is not easy for me to find a solution to this problem:

  • There is an taxonomy which will consist of hundreds and mayby thousands of items. This taxonomy is called "Stones".
  • There is a custom post type called "item" (for sale) which consists of 1..n "stones" in the "main part" and of 1..n "stones" in the "additional part"

In other words the same taxonomy should appear using different labels for the same post type twice (Stones contained in the main part and stones contained in the additional part).

Of course it would be easy just to create two different custom taxonomies, but the challange here is that the items of the two taxonomies should be identical and should be identically inserted / updated / deleted.

Can somebody think of an solution for this?

2 Answers 2

1

You'll have to store some sort of meta data with each post that denotes the relationship of each term. Hide the normal taxonomy meta box and provide your own meta box UI that allows selection of terms, and upon save adds post meta with term + type of relationship, in addition to setting the object terms.

1
  • Will give this a try.
    – Blackbam
    Commented Apr 29, 2014 at 14:42
1

Not to always resort to Plugins when unnecessary, but Advanced Custom Fields has a Taxonomy Field. Allows you to stick another dropdown/etc. field on your post type.

If interested, I'd look into where it stores it. If stored in the wp_terms table, you will need a way to differentiate between "Main" and "additional" parts.

EDIT

My idea for a solution:

  1. Roll your own metabox, and hide/disable the default one for this post type.
  2. slam 2 select fields in it, populated with all of the Stones terms
  3. add a little JS to make sure that when an item is selected in one, it's hidden from the other dropdown.
  4. When saving, save the selections in the wp_terms table, AS WELL as postmeta.

This will give you the ability to include these items in "by Stone" searches (attached directly to the term, so you can use WP_Query's tax_query), they will appear in categorized archives, etc. Annd you can check on postmeta to see which is the primary_stone and which is the additional.

2
  • Would be great to find a solution which works without using this Plugin. Of course I am interested in how they achieved this.
    – Blackbam
    Commented Apr 29, 2014 at 14:44
  • Added some thoughts to my answer for a solution. Commented Apr 29, 2014 at 15:06

Your Answer

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

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