Changing WP_Query params with url Query Var
:)
I've used WP_Query to display there posts (travels) here http://boost19.delavec.si/wordpressP/produkti/
So... I've got this WP_Query that is looping through my custom posts
?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?
?php $loop = new WP_Query( array(
'post_type' = 'product',
'meta_key' = 'product_price',
'orderby' = 'meta_value_num',
'order' = 'ASC',
'posts_per_page' = 4,
'paged' = $paged) ); ?
?php while( $loop-have_posts() ) : $loop-the_post(); ?
div class="av_one_third" style="display: inline-block; width: 20%; margin-bottom: 3%; text-align: center; margin-left: 3%;"
div class="card rounded-0 bg-light mb-3" style="width: 225px; height: 325px; text-align: center"
h5 class="card-title"?php the_title(); ?/h5
a href="?php the_permalink(); ?"
?php the_post_thumbnail(); ?
/a
pWe are going to ?php the_field('product_place'); ?/p
pProduct price: ?php the_field('product_price'); ?€/p
?php if(get_field('product_discount_price')): ?
h4Discount: ?php the_field('product_discount_price'); ?€/h4
?php endif; ?
pWe are going on ?php the_field('product_date'); ?/p
/div
/div
?php endwhile; ?
And I wish to add like 'sorting' action to it - I was wondering if I could change the 'order' to 'DESC' for starters?
I've tried and read different things like https://premium.wpmudev.org/blog/building-customized-urls-wordpress/ https://codex.wordpress.org/WordPress_Query_Vars
and tried this with no avail ;
http://boost19.delavec.si/wordpressP/produkti/?order=DESC or http://boost19.delavec.si/wordpressP/?post_type=productorderby=meta_value_nummeta_key=product_priceorder=DESC
which doesn't return true values that is should.
Anyone faced anything like that? Or if anyone has any other ideas how to tacke this sort by price thing?
Btw I'm using advanced custom fields - the name for the price field is
product_price