I basically want to replace the default taxonomy metabox (with the checkboxes) for my custom post type. I've added the basic code of the metabox below.
The problem I'm having is that I love the idea of the "field_type" => "select_tree" setting, but it seems to have some limitations.
Am I correct that...
"context" => "side"and always shows as
"context" => "normal"so it ends up below the content textarea instead of to the right side of it?
Note that for select_tree, checkbox_list, checkbox_tree, the multiple setting is always set to true.
$metaboxes = array( 'id' => 'my_product-info', 'title' => __('Product information', 'my-textdomain' ), 'post_types' => 'my_product', 'context' => 'side', 'fields' => array( array( 'name' => __('Product Category', 'my-textdomain'), 'id' => 'taxonomy', 'type' => 'taxonomy', 'taxonomy' => 'product_cat', 'field_type' => 'select_tree', ), ) );
Hi Anh Tran,
Meta box, I think. Not entirely sure what you mean here?
In my sample code it is set in the root level of the array, not in the nested "fields" key. Did you mean that?
When I change out the type=taxonomy for type=text for example, it jumps over to the side. Is this because the title/parent/child are too wide for the sidebar maybe?
Okay. Did not get that from the documentation. Thanks for clearing that up.
Have you ever drag and drop the meta boxes? If you have, then WP will save the position/location of them and makes the "context" param not working. The data is saved in the user meta
Deleting this user meta from the database will make the context work again.
Please try that. It's the only reason I think affects the wrong location.
I stand corrected, that was the case.
I was in the understanding that ordering of metaboxes was done in a cookie, not in the usermeta table.
This solved my problem, thanks!