How can I add a meta-box to the posts editor containing all items of a custom taxonomy as checkbox?

I have a custom hierarchical taxonomy containing only two levels of items. First Level the title, second level items of the taxonomy.

Is it possible to add a “meta box” to the posts editor of WordPress, so all elements in the second level are shown as checkboxes, first level as title and the author can select one or more of the item?

eg.

<h2>Bathrooms</h2>
<input type="checkbox"/> Bath tub
<input type="checkbox"/> Shower
...

<h2>Living Room</h2>
<input type="checkbox"/> Dining Table
...

aso.

There are plenty of items in this taxonomy, so I think the “normal” way to select taxonomies in the sidebar of the editor might not be enough.

Update: In the mean time I changed some things and found, that if I just move the taxonomy box to the left on the editor it’s good enough for what I want.

If I want to show checkboxes and items of the custom taxonomy on the frontend I am using the following snippet:

        <?php
        $addFeatureGroups = get_terms('additional_features', array('hide_empty' => false, 'parent'=> '0'));
        foreach ($addFeatureGroups as $group){
            ?>
            <div class="form_row clearfix">
                <div style="float:left;"><label><?php echo $group->name;?></label></div><div style="padding-left: 195px;">
            <?php
            $items = get_terms('additional_features', array('hide_empty' => false, 'parent' => $group->term_id));
            foreach ($items as $item){
                ?>
                <span class="fl user_define" title="<?php echo $item->description;?>">
                    <input name="additional_options" type="checkbox" value="id-<?php echo $item->term_id;?>">
                    <?php echo $item->name;?>
                </span>
                <?php
            };
            ?>
            </div></div>
            <?php
        };
        ?>

Thanks.

1 Answer
1

<h2>Bathrooms</h2>
<input type="checkbox" name="bathrooms_id[]" value="bath_tub_id" /> Bath tub
<input type="checkbox"  name="bathrooms_id[]" value="shower_id" /> Shower
...

<h2>Living Room</h2>
<input type="checkbox" name="livingroom_id[]" value="dining_table_id" /> Dining Table

Leave a Comment