I’m having have a checkbox filtering issue in wordpress - Please have a look at the details below - Any help would greatly be appreciated!

What I’ve built:

I created three custom taxonomies of topics, skateboard and wheels.

I have a page that displays the taxonomies with the slug that looks something like this:


I created another taxonomy called regions with three locations North America , South America , All of America.

I rendered the regions as check boxes onto the page for filtering.

My issue:

The page /topics/skateboard/wheels is rendering all of the posts associated to its respective taxonomies yet when I select North America - The query returns all of the posts from the database that has North America checked.

I can’t get the filter to only return posts associated to this slug topics/skateboard/wheels.

So i’d like to return posts with North America checked marked only associated to topics -> skateboards -> wheels.

So all of the wheels in North America.

Form with checkboxes:

            if($_GET['regions[]'] && !empty($_GET['regions[]'])) {
              $regions = $_GET['regions[]'];

            <form action = "" method="GET">
                $terms = get_terms([
                  'taxonomy' => 'regions',
                  'hide_empty' => false
                foreach ($terms as $term) :
                  value="<?php echo $term->slug?>"
                    (isset($_GET['regions']) && in_array($term->slug, $_GET['regions']))
                    ) ?>
                  <?php echo $term->name; ?>
            <?php endforeach; ?>
            <button class="uk-button-filter" type="submit"> Apply Filter </button>

The Query:

              $terms = get_terms( 'regions' ); 
              $term_ids = wp_list_pluck( $terms, 'slug' );
              $args_one = 
                  'post_type' => 'post',
                  'tax_query' => array(
                          'taxonomy' => 'regions',
                          'field' => 'slug',
                          'terms' => $_GET ? $_GET['regions'] : $term_ids,
                      'relation' => 'AND',


The Results:

      $the_query = new WP_Query( $args_one );

    // The Loop
    if ( $the_query->have_posts() ) {
    while ( $the_query->have_posts() ) {
        $the_query->the_post(); ?>


        <?php echo get_the_title();  ?>


    <? }
    } else {
    // no posts found
    /* Restore original Post Data */


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.