How to set taxonomy terms from multiple taxonomy fields

Support General How to set taxonomy terms from multiple taxonomy fields

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #38540
    shmaltzshmaltz
    Participant

    Hi!

    I have a clonable group, which contains a few Taxonomy Advanced fields (saves taxonomy to meta).

    When I save the post, I want to be able to save the terms that are in the taxonomy advanced fields to the post terms.

    Being that the Taxonomy Advanced field is clonable, it means that each post may have multiple taxonomy terms.

    Is there a way to save these terms to the correct taxonomy terms when saving the post?

    (I tried using the regular taxonomy field (that saves to terms), but it doesn't seem to work because it's in a clonable field)

    Thanks!

    #38544
    Long NguyenLong Nguyen
    Moderator

    Hi,

    It is possible. If you are familiar with coding you can create some lines of code to set the post terms. Please read more on the documentation
    https://docs.metabox.io/actions/rwmb-after-save-field/
    https://developer.wordpress.org/reference/functions/wp_set_object_terms/

    #38569
    shmaltzshmaltz
    Participant

    Thanks!
    Before I do that I want to make sure, is there no way to create a clonable group with a regular taxonomy field (that saves to terms), and grab all the terms and save them when the post is saved?
    e.g.
    |-Clonable Group
    |--Text Field
    |--Taxonomy(color) (only allow one taxonomy to be selected) value=red
    __________________
    |--Text Field
    |--Taxonomy(color) (only allow one taxonomy to be selected) value=blue
    __________________

    When the post is saved, I want the values "red" and "blue" to be saved to the taxonomy "color".
    Is this possible?

    #38573
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The taxonomy field only works when you set it as a top field, it does not work as a subfield in a group or a field in a custom block.
    You need to use the field taxonomy_advanced to save the post meta and use that value to update the post terms.

    Please read more on the documentation https://docs.metabox.io/fields/taxonomy-advanced/
    https://docs.metabox.io/fields/taxonomy/

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.