jeudi 26 mai 2016

Update wp_query with AJAX form checkbox

I've been searching for days now. I've got a website with a custom post type and some taxonomies in it. My homepage is looping all the custom posts with post type "values".

$main_query = new WP_Query(array(

'post_type'     => 'values',

'post_status'   => 'publish',

'order'         => 'ASC',

'orderby'       => 'menu_order',

'showposts'     => '40',

'paged'         => $cur_page,

));

This is the loop section:

<?php if( $main_query->have_posts() ): ?>
                <div class="featured-container col-md-12">

                        <div class="row">                       

                        <?php $counter = 0; ?>

                        <?php while( $main_query->have_posts() ): ?>

                            <?php

                            $main_query->the_post();

                            include(locate_template( 'includes/values_list_loop.php' ));

                            ?>

                        <?php endwhile; ?>
                        </div>
                    <!-- pagination -->
                    <div class="blog-pagination col-md-12">
                       <ul class="pagination">
                          <?php echo $pagination; ?>
                       </ul>
                    </div>
                </div>
                    <?php endif; ?>
                    <?php wp_reset_query(); ?>

On the same page right before the loops start I have a few checkboxes that contains a list of values_tag a taxonomy of the custom post type values.

Example checkbox:

<input type="checkbox" name="value_tag_1" class="checkbox_click" />

Every custom post in the loop contains a values_tag. I want the form to be clickable and reload the loop specific to the selected values_tag, I want this to be multiple clickable. I see a lot of examples but whatever I try I can't manage to get it to work. I hope you guys could help me with this.




Aucun commentaire:

Enregistrer un commentaire