Custom Taxonomy and Advanced Taxonomy

Support MB Builder Custom Taxonomy and Advanced TaxonomyResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #13962
    designerabreu@gmail.com[email protected]
    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

    #13977
    Anh TranAnh 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
    designerabreu@gmail.com[email protected]
    Participant

    Thanks a lot. solved

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