WordPress Custom post query sorting does not work

I created a custom WP query to collect products that have 3 different taxonomy values in them and sorted them by price using the following:

$my_products = new WP_Query(
            array(
                'orderby' => 'meta_value',
                'meta_key' => 'regular_price',
                'order' => 'ASC',
                'paged' => $paged,
                'post_type' => 'product',
                'tax_query' => array(
                    'relation' => 'AND',
                    array(
                        'taxonomy' => 'pa_width',
                        'field' => 'slug',
                        'terms' => $width),
                    array(
                        'taxonomy' => 'pa_aratio',
                        'field' => 'slug',
                        'terms' => $aratio),
                    array(
                        'taxonomy' => 'pa_dia',
                        'field' => 'slug',
                        'terms' => $dia)
                )));

The query returns results and is mostly fine but some the products appear out pof place – take a look at http://www.tyrebroker.ie/your-search/?width=245&aratio=40&dia=18

Read More

I dont know how to resolve this as I have trawled through the database and product details to see what could be causing the issue.

Any suggestions – thanks

Related posts

Leave a Reply

1 comment