• Resolved webziss

    (@webziss)


    Hi!

    I am wondering how can I make a query that sorts the posts by rating values (DESC).
    I am using this code: https://gist.github.com/danielpowney/716b65779dd402743c59#file-sort_wp_query-php and I am making the query using AJAX on button click but the ajax call responding with 500 Internal Server Error (Referrer Policy:no-referrer-when-downgrade).

    This is the query:
    $query = new WP_Query( array(
    ‘post_type’ => ‘post’,
    ‘post_status’ => ‘publish’,
    ‘tax_query’ => array(
    ‘relation’ => ‘AND’,
    array(
    ‘taxonomy’ => ‘category’,
    ‘field’ => ‘term_id’,
    ‘terms’ => $category,
    ),
    array(
    ‘taxonomy’ => ‘area’,
    ‘field’ => ‘slug’,
    ‘terms’ => $area,
    ),
    ),
    ‘mrp_sort_highest_rated’ => true

    ) );

    I need to query the taxonomies and sort by rating.
    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter webziss

    (@webziss)

    Somebody?

    Plugin Author dpowney

    (@dpowney)

    Hi there,

    The code snippet you are using is for the Pro version and unfortunately it will not work with the free version.

    The post rating is also stored in the post meta table. So you can do this:

    $q = new WP_Query( array( ‘orderby’ => array( ‘mr_rating_results_star_rating’ => ‘ASC’ ) ) );

    Daniel

    Thread Starter webziss

    (@webziss)

    ok, thank you.
    I will tell my client to buy the pro version.

    Thread Starter webziss

    (@webziss)

    Hey Daniel.

    The query is not working for me on the pro version.
    I replied to your last email. please respond.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sort posts by rating’ is closed to new replies.