Forum: Premium Settings

This forum is closed for new topics. However, you can still search for a solution in the old topics. For technical support related to the Premium Settings premium extension please open a new premium support ticket.

[Not resolved]Orderby Price / Rating on Products post types in results

Forums Premium Settings Orderby Price / Rating on Products post types in results

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #47897

    Have been stuck on this for some time.

    I would like to have visitors able to order their search results by price and by rating.

    The results are woocommerce products.

    I can add the filter to the search form to narrow down the price BETWEEN, and I have orderby post_date / post_title working fine, but orderby price is beyond me it seems.

    Have tried a few thing by adapting the example coding given here –


    elseif ( $orderby_value == ‘price’ ) {
    $meta[‘key’] = ‘_regular_price’;
    $clauses[‘orderby’] = ‘meta_value_num’ => ‘ASC’; }

    $clauses[‘orderby’]= $wpdb->prefix.’postmeta.meta_key => _regular_price’, ‘meta_value-num’;

    but just end up with a blank screen.

    I assume that being able to have BETWEEN working means that it must be possible, I just am not good enough with WP/PHP to figure out how it works.

    Any help would be appreciated.



    Thinking about this – if an orderby price isn’t possible – then if the BETWEEN numerical custom fields section could be displayed as a slider then that would be a good compromise.


    Hi Sharon,

    I need to do exactly the same, ‘Order WooCommerce products in the search results list by price low to high’. Did you manage to make this work please? If so, are you happy to share your code with me please?



    Chris Homan

    I was trying to do the same and I think I got it to work 🙂

    This is the code I used (snapped from the posts locator dropdown example:

    I attached a file which contains the complete code – the content has to be added to your functions.php file

    You must be logged in to view attached files.

    Hi Chris,

    Thank you, so much. I put this on the back burner, until my PHP skills improved. I manage to create the odd WordPress filter and hook but I am not expert at PHP. I haven’t tried your code yet, but I am going to, hopefully tomorrow.

    I’ll feed back.

    Thanks again.


    I know its 3 year later.. But mine only sorts by distance. Nothing else.



    I am able to set it only for distance, post_title, ID ( post ID ), post_date ( date created ), post_modified ( last modifed ) and post_type.

    I am trying to set the order by average rating and price of my products, with Geo my WP premium setting extension, but at the moment I don’t have any success. Do you have some news on it?

    I also need to show the customer review per product under the name of each product. Someone of you know something about it?

    Thank you in advance.



    I tried the code by @Chris Homan and it has function very well.
    But at the moment I am not able to show the rating under the name of each product in the list of searching results.

    Someone can help me?

    Thank you

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.