2

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
  • The code snippet you've posted - that produces the title-checkbox layout you're after, right? What are you stuck on? Commented Nov 9, 2012 at 14:01

1 Answer 1

0
<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
1
  • 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
    Commented Apr 3, 2012 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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