• Resolved marcdegagnelob

    (@marcdegagnelob)


    Hello Pods team,

    I have a customer site I have not been on for a while and noticed something that is unexpected.

    I have used Pods to add some CPT and custom fields in relation with WooCommerce products and for some reason now I have two fields of the same taxonomy but have different field types showing in the individual CPT page. One is a drop-down, and the other is a set of checkboxes.

    I am pretty sure the drop-down was set from the beginning, but the other not, simply because the taxonomy settings are set as a drop-down and this field as a set value for each CPT.
    While the drop-down was used from the beginning, no taxonomies are showing in the column in the edit list page of the CPT and the column is simply empty.

    The only way I can have the taxonomy column propagated with values is by using the second set of taxonomy that are checkboxes.

    How can I fix this, remove the radio input and have the taxonomy column propagated with the values?
    Do you think that some of the Pods Tool could do the trick?

    Thanks, (modifié) 

Viewing 1 replies (of 1 total)
  • Plugin Support Paul Clark

    (@pdclark)

    Feel free to provide more information if this is not the case, but it sounds like you might have a taxonomy connected in two ways: once as a relationship field, which is a Pods user interface stored in post_meta as related taxonomy term IDs, and the other as a WordPress core taxonomy connection, found under the Connections tab when editing the Pod or Taxonomy.

    The first would show up in the meta field groups, while the second would show up in the sidebar column —?the same user interface as WordPress core categories and tags.

    The key difference between these two, other than the source of the user interface, is the storage: one puts related IDs in post_meta, while the other uses three core WordPress tables dedicated to taxonomy term relationships.

    An example of converting one datatype to the other — a relationship field to a core taxonomy —?can be found at https://docs.pods.io/code-snippets/update-taxonomy-value-stored-relationship-field/

    The key function in this example is wp_set_object_terms(), which is the WordPress core function for setting a post object’s relationship to terms from a given taxonomy, such as categories.

    In the example, the pods_api_post_save_pod_item_films is specific to when a films Pod is saved in wp-admin. One could similarly loop through all posts of a certain type with WP_Query, get_posts() or pods()->find(), retrieve the relationship field taxonomy term IDs, and use wp_set_object_terms() within that loop.

    The reverse, a taxonomy connection to a Pods relationship field, would be achieved with wp_get_object_terms() and pods()->save()

Viewing 1 replies (of 1 total)
  • The topic ‘CPT with taxonomy relation as Drop-down showing as drop-down and checkboxes’ is closed to new replies.