taxonomy field not saving terms for the custom post

Support MB Builder taxonomy field not saving terms for the custom postResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #15547
    Akram ul haqAkram ul haq
    Participant

    Hi,

    No doubt metabox io saved a lot of time but I need your help here badly. I have a taxonomy which I don't want to show up on post screen but want to show in a group once certain key is selected. I am doing it right and my field is showing as well.

    But once I save the field it did not set to my post as taxonomy but saved in the post meta. How can I do that with taxonomy field ? As documentation states that I should be able to do it but what's causing it to not save, I copied code from your taxonomy page and taxonomy field is showing fine.

    Only issue is its saving to meta box table not setting as post terms.

    Thanks

    #15562
    Anh TranAnh Tran
    Keymaster

    Hi Akram,

    Did you put the taxonomy field in a group? Only in that case, the taxonomy terms are saved in the group's meta value and don't set the post terms.

    #15574
    Akram ul haqAkram ul haq
    Participant

    Hi Anh,

    Thanks for your replies. Yes my friend I did so and I need that as well. Than can you provide me any better solution for this ? So, I can set it to work like I needed. Because I don't want to show taxonomy in the post edit screen for certain requirements but want to have inside my group ...

    Will I have to set those terms as my own ? Or any better solution is available for this ?

    Thanks

    #15584
    Anh TranAnh Tran
    Keymaster

    Hi Akram,

    If you want to set post terms, you have to move the taxonomy field outside the group. You can use MB Conditional Logic to hide the field if you want. If you still need to keep it inside a group, then there's no way to achieve that.

    #15587
    Akram ul haqAkram ul haq
    Participant

    Hi,

    Thanks for your reply but I personally feel its not a professional way by any means .. as it adds limitation to metabox io ... !!!

    Nothing is impossible so the answer is I have to do it at my own ... a lot of hype came to end that metabox io does every thing and bla bla bla ... 🙁

    Can I rate this plugin any where ? I have to put my frustration there ...

    Thanks by the way ...

    #15588
    Anh TranAnh Tran
    Keymaster

    Hi Akram,

    Sorry to make you feel like that. What I meant is that's the default behavior of the fields.

    You still can change the behavior with the plugin action, like this:

    add_action( 'rwmb_after_save_post', function( $post_id ) {
        $group = get_post_meta( $post_id, 'group_id', true );
        $terms = $group['terms'] ?? [];
    
        wp_set_post_terms( $post_id, $terms, 'your_taxonomy' );
    } );
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.