Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterNo problem, all done! I've just added
composer/installersand set the package type towordpress-plugin. Now you can use it ๐April 24, 2018 at 1:37 PM in reply to: How to filter value of spesific field before saving it to DB #9348Anh Tran
KeymasterYou can use
rwmb_{$field_type}_valueorrwmb_{$field_id}_value. Please see this docs.April 24, 2018 at 11:22 AM in reply to: Prevent terms order being overwritten when updating post #9346Anh Tran
KeymasterNo problem. The MB Custom Taxonomy only set the taxonomy parameters. Other things are handled by WordPress itself.
I think we can close this topic :). Have a nice day!
April 24, 2018 at 10:18 AM in reply to: Prevent terms order being overwritten when updating post #9344Anh Tran
KeymasterOoops, I was thinking you're using the
taxonomyfield from Meta Box. If you're using the WordPress's core meta box for post tag, then it's out of the scope of the plugin. Maybe you should open a ticket for WordPress team?April 24, 2018 at 9:37 AM in reply to: Prevent terms order being overwritten when updating post #9340Anh Tran
KeymasterHi,
I'm not sure if the select advanced library support changing order of selected items. AFAIK it doesn't. That's why I was curious about how did you set the order for the terms in the previous reply.
The current workaround pushes the selected items to the bottom of the list and un-selected items to the top. It's kind of the unfriendly experience for users, but that's the only way to preserve the order of selected items. (You can see the details in the Github link I posted above. It's worth noting that this is a temporary solution, as it's NOT supported by the select2 library).
By the way, can you post the code you use for post_tag with Meta Box?
Anh Tran
KeymasterHi Mark,
It's kind of impossible for group. Group saves value as an serialized array, that's unable to query by. If you really need to query by a field, please make it a standalone field, not in a group.
Anh Tran
KeymasterFinally, I can make it work. I wrote the documentation for Composer here. Please try that and let me know how it goes.
Anh Tran
KeymasterHello,
We're working on the user profile update that allows you to create user login / register and edit profile page in the frontend. The release plan was last week, but there're some bugs that we're fixing. We'll let you know when it done asap.
Anh Tran
KeymasterWell, you can do a simple query like this:
global $wpdb; $values = $wpdb->get_result( $wpdb->prepare( "SELECT * FROM your_table WHERE ID=%d", $post_id ), ARRAY_A );Anh Tran
KeymasterHi, why don't you just use
get_post_meta()instead? Using the helper function will run through all custom fields and prepare the values for all of fields, which is an extensive job. It's not a good choice for performance.Anh Tran
KeymasterHey Kasia, no problem at all. I'm glad you figured it out!
If you need any help, please let me know.
April 23, 2018 at 12:46 PM in reply to: Prevent terms order being overwritten when updating post #9315Anh Tran
KeymasterHi again,
I think I have resolved this issue. I've just pushed a commit on Github to make it work. Can you please try it.
This is the code I use to test:
add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) { $meta_boxes[] = [ 'title' => 'Test: Taxonomy term order', 'fields' => [ [ 'id' => 'm_tax', 'type' => 'taxonomy', 'taxonomy' => 'custom-category', 'field_type' => 'select_advanced', 'multiple' => true, ], ], ]; return $meta_boxes; } );Note that
multipleis set totrue. It's required to select multiple terms.April 23, 2018 at 11:58 AM in reply to: Prevent terms order being overwritten when updating post #9312Anh Tran
KeymasterI understand.
There's a technical difficulty. The
select2, which is the library used for taxonomy field, doesn't support preserving selected order. I'm trying some workarounds posted on that issue to see if I can make it work in WordPress's case.Anh Tran
KeymasterHi, your select field is just a normal select without
cloneormultiple, so to get its value, simply remove theforeachloop in your code:$value = rwmb_meta( 'scadenza_prodotti_rinnovabili' ); echo $value;April 23, 2018 at 9:07 AM in reply to: MetaBox doesn't saves and it doesn't work with selected category #9310Anh Tran
KeymasterHi,
There are several things in this case:
- I see you create 2 groups: 1 group for categories A & B, 1 group for categories C & D. And you put the conditions in each fields of the groups. That's not good for performance because the plugin has to process all fields. Why don't we put the conditions for the groups only? So we need only 2 conditions instead of 10?
-
The value for the category select actually is the category ID, so we have to use IDs instead of category slug or name.
-
The category select has a field type
checkbox_tree, which means its value is an array. We can't use operator=in this case. Instead, usecontains.
I have adapted your code and made a fix here (please change the categories' IDs to match your case):
Here is my test:
-
AuthorPosts