Cannot rank the revies by their stars
-
Dear users/moderators,
I am trying to rank the reviews based on their stars given. I have read the FAQ however when I try to paste this code;
$query = new WP_Query([ 'meta_query' => [ 'relation' => 'OR', ['key' => '_glsr_ranking', 'compare' => 'NOT EXISTS'], // this comes first! ['key' => '_glsr_ranking', 'compare' => 'EXISTS'], ], 'order' => 'DESC', 'orderby' => 'meta_value_num', 'post_status' => 'publish', 'post_type' => 'page', // change this as needed 'posts_per_page' => 10, // change this as needed ]); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $average = sprintf('%s (average rating: %s)', get_the_title(), get_post_meta($post->ID, '_glsr_average', true) ); $ranking = sprintf('%s (ranking: %s)', get_the_title(), get_post_meta($post->ID, '_glsr_ranking', true) ); apply_filters('glsr_debug', 'Site Reviews is not installed', $average, $ranking); } wp_reset_postdata(); }
to the Customization –> Theme editor –> index.php, nothing happens. I am using Astra as my theme. Most probably I am writing this code to the wrong place. I could not find a suitable place. Can you help me?
Best regards,
BarkinThe page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Cannot rank the revies by their stars’ is closed to new replies.