• Resolved justsomeone

    (@justsomeone)


    Hi community,

    I’ve created a custom post type “offer” and two custom taxonomies “offertype” and “offercategory”, both added to “offer” via a relationship field within the “offer” pod.

    I did this to have all the information that the client needs to touch within the pods custom field area. However during testing I figured out that there is no actual relationship. I added the “offertype” as a single select dropdown field and the “offercategory” as a multi select autocomplete. But when I create a new offer and assign a offertype and multiple categories they are stored within the offer but when checking the taxonomies I can see that they are not actually related.

    Am I doing something wrong? The setup was pretty straight forward and I’m wondering that this is not working.

    Thanks in advance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter justsomeone

    (@justsomeone)

    Solved it by myself.

    For anyone interested: unfortunately there is no such built in functionality. However the pods team provided a useful code snippet for this[1]. I’ve adapted the code snippet to my needs and put it into an own small plugin (using a template[2]) so that I can easily load it into WordPress.

    [1] https://docs.pods.io/code-snippets/update-taxonomy-value-stored-relationship-field/
    [2] https://github.com/srikat/my-custom-functionality

    • This reply was modified 4 years, 1 month ago by justsomeone.

    I am just in the early stages of exploring how to best apply Custom Taxonomies, so I am trying to understand your approach of using taxonomies in conjunction with relationship fields. I think I understand the solution you provided and how it works, but I don’t think I understand the problem that you were trying to solve. That is, why would you want to select a value from a simple list in a relationship field and then translate the selected value into a taxonomy term rather than just selecting the taxonomy term directly? What am I missing?
    Your feedback would be appreciated.

    Thread Starter justsomeone

    (@justsomeone)

    Hi @jjci ,

    why would you want to select a value from a simple list in a relationship field and then translate the selected value into a taxonomy term rather than just selecting the taxonomy term directly

    Basically: KISS (Keep it simple & stupid) – For the client.

    Having all items my customers need to touch within a single box keeps it as simple as it could be for the customer. With a Label & Description for each field all of the options are basically self explanatory.

    My goal: I want to have one taxonomy as a single select value and another as a multiple select (as described in the first post).
    My options:
    – Use a 3rd party plugin to make a taxonomy single select
    – Explain the customer to only select one of the taxonomy options
    – My approach: use relationship to assign taxonomies via single select and multi select custom field

    So with the approach I took I do not require a 3rd party plugin to make a taxonomy field single select (basically a plugin is used though but I wrote it and it’s just a small function) nor do I need to explain my customer how he needs to use the taxonomies and I reduce the complexity for them.

    I hope this answers your questions ??
    And of course, I’m also glad for any other alternatives.

    Cheers

    Thanks for the detailed explanation(s). All good points.
    I am experimenting with PODS taxonomies as a means to set ‘status’ values at various levels of a hierarchy of PODS CPT tables. That is, I have three tables in a parent->child->grandchild relationship as well as a number of other related tables. I am hoping to use a common taxonomy to set the ‘enabled/disabled/suspended’ status value for each table entry where the taxonomy setting for a given entry MAY be affected by the setting(s) of the parent and/or grandparent settings above it. The alternative was to introduce 2-3 separate ‘status’ fields into the structure of each CPT, but that would just become a nightmare to develop/maintain, so I doubt I will go with that particular solution. It is so much easier to assign one (or more) taxonomies to a give CPT and to use common filter-level code to evaluate the taxonomy terms and set the status value(s).

    The biggest problem I am having right now is evaluating the taxonomy terms for a given table entry. This is a WordPress issue rather than a PODS issue, but it’s still an issue. Just have to do more research, I guess… ??

    @justsomeone, thanks for posting the code snippet. I couldn’t get it to work however, the taxonomy does not update – did you have any problems getting it to work, or could you share your customised version to see if it works for me please?

    Thread Starter justsomeone

    (@justsomeone)

    Hi @pixelshrink ,

    haven’t had much issues getting the snippet to work. On my latest project I didn’t even create a custom plugin and just used “Code Snippets” plugin and pasted the code there. You just need to make sure that all variable names are fitting to your custom types.

    Here’s my setup:

    1. Custom post type “angebote” & custom taxonomy “angebotstyp”: screenshot
    2. Add taxonomy relationship field to custom post type “angebote”: screenshot
    3. Create code snippet or custom plugin: screenshot (make sure to adopt all field names accordingly)

    Let me know if this works ??

    If not, please share some details so that I can provide further help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom taxonomie not assigned via relationship field’ is closed to new replies.