Change order of posts

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:

Read More
<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.

Related posts

1 comment

  1. 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):

     $args = array(
       'post_type' => 'your_post_type', // I don't know what this is
       'meta_key' => 'your_key', // I don't know what this is
       'orderby' => 'meta_value_num', // only for numbers; use "meta_value" for alphanumerical keys
       'order' => 'ASC',
       'meta_query' => array(
           array(
               'key' => 'your_key',
               'value' => array('your_value'), // can be more than one
               'compare' => 'IN', // see the Codex for other values
           )
       )
     );
     $query = new WP_Query($args);
    

    Reference

    https://codex.wordpress.org/Class_Reference/WP_Query

Comments are closed.