• Resolved tavomenas

    (@tavomenas)


    Hi,
    I was wondering if it’s possible to show trough [site_reviews] shortcode first the best ranked reviews, basically ordering reviews display from higher ranked to lower (without hiding low reviews).

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    /**
     * Sort reviews by rating (high to low)
     * Note: because this replaces the default sorting, it will also disable pinned reviews from showing first
     * Paste this in your active theme's functions.php file.
     * @param WP_Query $query
     * @return void
     */
    add_action( 'pre_get_posts', function( $query ) {
        if( $query->get( 'post_type' ) == 'site-review' ) {
            $query->set( 'meta_key', 'rating' );
            $query->set( 'orderby', 'meta_value_num date' );
        }
    });
    • This reply was modified 6 years, 5 months ago by Gemini Labs.
    Thread Starter tavomenas

    (@tavomenas)

    Works perfectly. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ordering from higher ranked reviews’ is closed to new replies.