I am trying to gather specific information in a select tag in order to filter pages. A have several training pages with same prices (for instance : $80, $120, $500, etc...). The problem is when a query the custom field 'price_1' (the varible price), wp_query retrieves all the pages with prices, and most of them have the same price.
so my select tag looks like :
Select a price : $80 $80 $80 ... $120 $120 $120 $120 $120 $500 $500 $500 $500 $500 ...
I would like to gather same prices values in one and when click on one of them display all the training pages releated.
Select a price : $80 $120 $500 ...
Thanks for your help if you have some ideas, at this point code is getting tricky.
P.S : Im using ACF plugin
Here is my code :
$args = array( 'post_type'=> 'page', 'posts_per_page' => -1, 'meta_key' => 'prix_1', ); $price_query = new WP_Query( $args ); <div class="col-lg-3"> <select name="page-dropdown"> <?php if( $price_query->have_posts() ) : while( $price_query->have_posts() ) : $price_query->the_post(); ?> <option value=""><?php the_field('prix_1'); ?></option> <?php endwhile; ?> <?php endif; ?> </select> </div>