• Resolved steklosvetlana

    (@steklosvetlana)


    Hello:

    I’m interested in defining relationships between custom taxonomies but I’ve been unable to find much in the way of documentation on this topic. What I’d like to be achieved is the following:

    1. There’s the ‘found_object’ custom post type.

    2. There’s the ‘materials’ custom taxonomy for terms like plastic, wood, glass, etc. attached to the ‘found_object’ post type.

    3. There’s also the ‘physical_properties’ custom taxonomy for, say, electrical conductivity and other properties that a given material is known to possess.

    4. I would like to assign the above properties to my materials so that the physical_properties taxonomy terms for each of the found_objects get auto-populated once the materials of an object are selected. I need this to let the user arrive at these objects by filtering them by physical properties directly (not by materials per se) using the FacetWP plugin.

    I vaguely understand that this can be done by setting up a relationship between my taxonomies by creating a relationship field. But other than that I don’t quite understand what to do.

    I would greatly appreciate your help or suggestions.
    Kind regards, Svetlana.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    Nothing does ‘auto population’ of taxonomy selections during input. FacetWP is for filtering, not for assignment of values. FacetWP does support our relationship fields when showing filtered content, but you might have to reach out to them (or us) for passing a taxonomy query that isn’t based on the first taxonomy but on the related taxonomy.

    Basically if you created a filter for ‘Physical Properties’ that would need to pass the related terms for Materials to filter the Found Objects that include those materials terms. There just needs to be a translation for the Physical Properties to Materials terms in the FacetWP filter.

    You’d probably have to write some custom WP/Tax Query that did a combination there, but it seems doable. This is definitely an advanced solution, so I’m going to flag this one to have our Lead Developer look at.

    Plugin Contributor Jim True

    (@jimtrue)

    Scott provided some feedback:

    In order to handle the population portion: you’d have to set that up with a pre-save or post-save hook probably; it would take the related physical_properties of any selected materials and save them to the found_object.

    What you’re really looking for is the ability to display all of the physical_properties of any materials on a specific found_object, but FacetWP doesn’t support deep traversal like that.

    You’d have to do something like that with custom PHP.

    Plugin Contributor Matt Gibbs

    (@mgibbs189)

    Good questions. Here’s the recap:

    1. “Found object” is the post type
    2. It contains a taxonomy named “Materials”
    3. The “Materials” taxonomy contains a relationship to a “Physical properties” taxonomy
    4. You want to let users filter “Found objects” by physical properties.

    Fortunately, this is totally do-able with FacetWP. It involves doing the lookups during the indexing process, and indexing the associated terms.

    Example: https://gist.github.com/mgibbs189/13c3c8ab80eb55f8cbf436273f959b26

    Plugin Contributor Jim True

    (@jimtrue)

    Awesome!! Thanks @mgibbs189 !! Do you mind if I add that code snippet to our Docs site? We get questions about these kinds of chained taxonomies often.

    Plugin Contributor Matt Gibbs

    (@mgibbs189)

    @jimtrue Go for it! And feel free to copy any code you find from https://gist.facetwp.com/ too

    Thread Starter steklosvetlana

    (@steklosvetlana)

    Thank you Jim, Scott, and of course Matt. Very grateful to you all and much encouraged by the fact that it’s doable. Now that I have the elegant gist by Matt, I think I’ll be eventually able to handle the problem, standing on the shoulders of giants. ??

    Plugin Contributor Jim True

    (@jimtrue)

    @steklosvetlana Can you elaborate on your eureka moment? That can help out others.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘relationships between custom taxonomies’ is closed to new replies.