1

I would like some help, I have this situation

Taxonomy = Location where

Brasil = Parent
- Acre = as first child
-- Rio Branco = another child
-- another city = another child

-Santa Catarina = as first child
-- Sao Bento do Sul
-- another city

I need create 3 dropbox [country] [state] [city] I did..

<form id="revenda">
         <?php
/** The taxonomy we want to parse */
$taxonomy = "localizacao";
/** Get all taxonomy terms */
$terms = get_terms($taxonomy, array(
        "orderby"    => "count",
        "hide_empty" => false,

    )
);
/** Get terms that have children */
$hierarchy = _get_term_hierarchy($taxonomy);


?>
    <select name="terms" id="terms">


        <?php
            /** Loop through every term */
            foreach($terms as $term) {
                /** Skip term if it has children */
                if($term->parent) {
                    continue;
                }
                echo '<option value="' . $term->slug . '">' . $term->name . '</option>';
            }
        ?>
        </select>
     </form>

so, I got the first dropdown select [country],

My problem is that I don't know how to create other selects getting first child either second one. Any idea?

1
  • As I realize, I will can not do it unless I use Ajax, so any one could help? – Patrick de Freitas Mar 16 '18 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.