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'm creating a form that loops through all the terms of a taxonomy. Multiple terms can be selected and they get passed in the url. I'm trying to get all the terms on another page but I'm only able to get the last one. I'm not sure if this is the best way to do this but if anyone can give me a tip as to what I'm doing wrong.

First, here is the form

                        <form method="get" id="searchProperties" action="<?php echo home_url()?>/filter-2/?">
                            <?php
                        $termsCounty = get_terms( 'County', array(
                              'hide_empty' => 0
                              ) );
                        echo '<ul>';
                            foreach ($termsCounty as $term) {
                                $termCounty = $term->name . 'PropertyFilter';
                                echo '<li><label><input type="checkbox" name="t"  value="il_' . $term->name . '">' .$term->name. '</label></li>';
                            }
                        echo '</ul>';

                        ?><input type="submit" value="FILTER"/>
                        </form>

And here is where the choices are accessed:

echo $term = $_GET['t'];

Any suggestions? Thanks in advance!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Use brackets in the name attribute:

'<input type="checkbox" name="t[' . $term->name . ']"  value="1">

Then get the keys with:

array_keys( $_GET['t'] );

See also: Settings API with arrays example

share|improve this answer
    
Thanks, that worked! –  graphical_force Jul 30 '13 at 1:52

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.