Custom Fields
Re-Envisioned
Support Meta Box Builder Custom Taxonomy and Advanced Taxonomy

This topic contains 2 replies, has 2 voices, and was last updated by  designerabreu@gmail.com 3 months, 2 weeks ago.

  • Creator
    Topic
  • #13962
    Resolved
    designerabreu@gmail.com
    Participant

    Hello, in my custom post the user can choose the category and tag of the product from among several options and I need that the choice is registered in a table with the rest data of the fields.

    If you use Taxonomy advanced, register the Ids (category and tags – separate columns). However in the post does not associate the categories and tags selected. Only use the Taxonomy field (but in this case it does not record the choices in the table).

    Only with a selection is it possible to carry out the 2 operations?

    Best Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #13977

    Anh Tran
    Keymaster

    Hi, I think that’s doable with some hook.

    Like you use a taxonomy_advanced to save the term IDs in the custom table. Then you hook to “after save post” to set the terms for the post.

    This is what I have in my mind:

    add_action( 'rwmb_YOURFIELD_after_save_field', function ( $null, $field, $new, $old, $post_id ) {
        $taxonomy = reset( $field['taxonomy' );
        wp_set_object_terms( $post_id, $new, $taxonomy );
    }, 10, 5 );

    Change YOURFIELD to your field ID.

    #14403

    Thanks a lot. solved

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.