Forum Replies Created
-
AuthorPosts
-
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:
April 20, 2018 at 3:46 PM in reply to: Prevent terms order being overwritten when updating post #9295Anh Tran
KeymasterHi,
Can you please tell me how do you set term order for a post?
When I go to WP database, I see the
term_orderis available only forterm_relationshipstable, which stores the connections between posts and terms. And the sooner a term in inserted, the lower order it has.When we update a post, Meta Box runs
wp_set_object_terms()function to update post terms. This function does these things:- Insert new terms relationships for the post
- Delete old terms relationships
- Reset the relationships order (
term_order)
The last step causes the problem you have met. You can check the source code of
wp_set_object_terms()function to see more details. Here is the screenshot of that part:https://imgur.elightup.com/YeYlGhc.png
The bad thing is this is the only function we can use to set post terms :(.
Maybe there's another approach to set the order? Have you tried
taxonomy_advancedfield?Anh Tran
KeymasterYes, that should work. There's no difference where we put the code. It's just the code :D.
Anh Tran
KeymasterHi,
I've just checked your code and couldn't see the error. Here is my test:
https://imgur.elightup.com/GBe6C7B.gif
Probably it's somewhere else. Can you check if there's any meta box that doesn't have any field?
I see you use
globto include all PHP files in a folder. Maybe there's a PHP file that doesn't contain meta box code?Anh Tran
KeymasterHello,
Can you share the code to register meta boxes? I guess there're some things missed there.
Anh Tran
KeymasterGreat post. How couldn't I find it! I'll check it now. Thanks for letting me know.
Anh Tran
KeymasterUnfortunately, there's no way to create private composer packages that are publicly accessible :(.
I've tried packagist.com and composer satis, but they work only if you have access to private repos already. So they work for us as an internal team, but not for public.
-
AuthorPosts