Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
The code snippet you've posted - that produces the title-checkbox layout you're after, right? What are you stuck on? –  Stephen Harris Nov 9 '12 at 14:01

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
share|improve this answer
    
Rajeev, thanks for your answer, but I was refering to the wp-internal taxonomy functionality... I want it as easy as possible to add or edit items in this list at a later point. I will update the original post with my current status - it's a bit further down the road. –  Patrick Apr 3 '12 at 8:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.