Forums › Forums › Search & Filter Pro › Sort Results by star rating
- This topic has 36 replies, 2 voices, and was last updated 8 years, 9 months ago by
Anonymous.
-
Trevor(Private) November 16, 2016 at 1:23 pm #70517
OK. I looked at the form ID 261) called
Search Form
.First looks:
Number of Results per page. In WordPress, use
-1
to specify unlimited 😉I added a Post Meta to the page to see if it I could find the ratings fields in the meta keys list. In the Options I changed
Get Options
toManual Entry
and then clickedBrowse Values
. This lets you see what is there 😉It shows only two possible values; 5 and 0. Is this correct?
I will leave that field there for now for you to look at.
Anonymous(Private) November 16, 2016 at 8:43 pm #70756Thanks for all the help Trevor, sorry to come back to you so quick but the code added in the results.php has just come up with ‘Array’ rather than the star rating?
while ($query->have_posts())
{
$query->the_post();?>
<div>
<h2>“><?php the_title(); ?></h2><p><br /><?php the_excerpt(); ?></p>
<?php
if ( has_post_thumbnail() ) {
echo ‘<p>’;
the_post_thumbnail(“small”);
echo ‘</p>’;
}
?>
<p><?php echo get_post_meta( get_the_ID(), ‘ratings_average’ ); ?></p>
<p></p>
<p><small></small></p></div>
<hr />
<?phpAnonymous(Private) November 16, 2016 at 10:03 pm #70783Managed to get it to show the number by adding true after the code…
while ($query->have_posts()) { $query->the_post(); ?> <div> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></h3> <p><br /><?php the_excerpt(); ?></p> <?php if ( has_post_thumbnail() ) { echo '<p>'; the_post_thumbnail("small"); echo '</p>'; } ?> <h6>Average Rating: <?php echo get_post_meta( get_the_ID(), 'ratings_average', true ); ?> Stars</h6> <p></p> <p><small></small></p> </div> <hr /> <?php
And I have added some text. It doesn’t actually show the 5 stars, that would be better if you know how to do that as in your example websites. At the moment it shows Average Rating: 5 Stars for example, just in text.
Alex
-
AuthorPosts