Tet banner

Custom Fields
Support General Limitations of select_tree (field_type)

  • Creator
  • #14734
    Resolved ComSi

    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...

    1. this overrides the "context" => "side" and always shows as "context" => "normal" so it ends up below the content textarea instead of to the right side of it?
    2. even though it is documented to have multi select enabled, this is not the case and only one parent / child term can be selected?

    Note that for select_tree, checkbox_list, checkbox_tree, the multiple setting is always set to true.

    Example code:

    $metaboxes[] = array(
        'id'         => 'my_product-info',
        'title'      => __('Product information', 'my-textdomain' ),
        'post_types' => 'my_product',
        'context'    => 'side',
        'fields' => array(
                'name'       => __('Product Category', 'my-textdomain'),
                'id'         => 'taxonomy',
                'type'       => 'taxonomy',
                'taxonomy'   => 'product_cat',
                'field_type' => 'select_tree',

    No multi-select and not in sidebar

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
  • #14743
    Anh Tran

    Hi ComSi,

    1. Context: this is set at meta box's level. Did you set for meta box or for the field?
    2. Multi-select: the documentation means the value saved for those field types are always multiple (you save both parent and children). But the selection for each level is only one. It's how the tree works.

    Hi Anh Tran,

    1. 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?

    2. Okay. Did not get that from the documentation. Thanks for clearing that up.

    Anh Tran

    Hi ComSi,

    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 meta-box-order_{screen id}:

    View post on imgur.com

    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!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.