taxonomy field not saving terms for the custom post
Support › MB Builder › taxonomy field not saving terms for the custom postResolved
- This topic has 5 replies, 2 voices, and was last updated 6 years, 2 months ago by
Anh Tran.
-
AuthorPosts
-
August 1, 2019 at 8:18 PM #15547
Akram ul haq
ParticipantHi,
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
August 2, 2019 at 11:07 AM #15562Anh Tran
KeymasterHi 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.
August 2, 2019 at 5:14 PM #15574Akram ul haq
ParticipantHi 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
August 2, 2019 at 10:01 PM #15584Anh Tran
KeymasterHi 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.
August 3, 2019 at 4:27 PM #15587Akram ul haq
ParticipantHi,
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 ...
August 3, 2019 at 4:52 PM #15588Anh Tran
KeymasterHi 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' ); } ); -
AuthorPosts
- You must be logged in to reply to this topic.