I made a post recently that did not explained myself right!
Come again, but with better explanations.
I need the “Select Option” change the order of query_posts.
My current code is:
<select>
<option selected="selected">Select order of posts</option>
<option>Highest price</option><!-- hypercart_meta_price "order=DESC" -->
<option>lowest price</option><!-- hypercart_meta_price "order=ASC" -->
<option>Discount in%</option><!-- hypercart_meta_discount "order=DESC" -->
<option>Release Date</option><!-- date "order=DESC" -->
</select>
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php query_posts( 'post_type=products&orderby=meta_value_num&order=DESC&meta_key=hypercart_meta_discount&key=price&cat=' .get_query_var('cat')."&paged=".$paged); ?>
<?php get_template_part("loop-products"); ?>
I just need to know how to change the query_posts using the “Select box”
Thank you for understanding. Hug!
UPDATED MY ISSUE, sorry for the inconvenience.
Your question is not very detailed. It is hard to work out exactly what you are doing but I am assuming that you are trying to sort posts by a custom meta
meta_key
/meta_value
. This the formula for that (annotated but basically lifted from the Codex):Reference
https://codex.wordpress.org/Class_Reference/WP_Query