Review Stars function/hook?

Posted in: Newspaper
Post count: 9

Hey!
Can you please help me out? 🙂
I’m experimenting with a listing page, and want to get the built in stars to show in list.
I’ve already used the code
<?php echo get_post_meta($post->ID, 'td_review_key', true); ?>
to show the actual value of the key.

I’ve got a custom page template sitting in the themes folder, but I can’t figure out how the fetch the stars in a div. I tried searching the classes and found the td_review.php… how do I hook into this?

I’ve got a loop going with this Boosnippet: http://bootsnipp.com/snippets/6A0M
But I can’t get the stars to show in front of the meta key value.

Post count: 23312

Hello Chrizze,

Unfortunately, I do not exactly understand where you want to place the Review score? As an example, if you want to display it through meta info container, you simply add the code above in this section, in a DIV, like this -> https://www.screencast.com/t/do8uGkW34qC and then if you will target this class, you can customize your review as you want.
If is not what you mean, please provide more details so I will be able to provide a more accurate response.

Thanks for your understanding!

Post count: 9

Ok, sorry for being a bit unclear. It’s difficult to explain in detail..
But here goes another try at it. 🙂


<div class="rating">
<span class="stars"><? What function should I put here? ?></span>
<span class="result_scoreKey"><?php setRating(get_post_meta($post->ID, 'td_review_key', true)); ?></span>
</div>

I have a small box, the right side shows the actual rating in numbers, the left side is where I want the stars to show up.

I can see that the stars use a class called td-icon-star. But I don’t know what function to call to render the stars in my custom page. Is there a hook? Or how do I show the actual stars?

Thanx for all the help! 🙂

Post count: 23312

Hello Chrizze,

Unfortunately, our theme does not have any such a simple option that allows you to do this. Your request needs to do some additional customizations through the code which is not a simple task and which involve some custom modifications. This feature is made in td_review.php core file like this -> https://www.screencast.com/t/KY0Urn76mpya This is not a simple task and if you are not aware of the steps which are needed to take in this regard, please consider hiring a freelancer/developer to help you because we cannot provide custom work at the moment, sorry!

Thanks for your understanding!

Post count: 9

Ok, yes. I suspected this might of been the case, so I went ahead and wrote my own code for this purpose.
It’s a bit of a dirty hack, but it works. I’ll figure something out down the road…

I’ll attach the code here, if anyone else wants to do the same. I run this function with the td_review_key, it then returns the correct amount of stars. (rounded up). It all lives inside a regular div with the review class and the same classes that the author review uses. Looks neat, now I only need to make customer review work the same. 😀

<?php
function setRating($number = 5) {
// Make it integer:
$stars = round( $number * 2, 0, PHP_ROUND_HALF_UP);

// Add full stars:
$i = 1;
while ($i <= $stars - 1) {
echo '<i class="td-icon-star"></i>';
$i += 2;
}
// Add half star if needed:
if ( $stars & 1 ) echo '<i class="td-icon-star-half"></i>';
}
?>

Post count: 23312

Hello Chrizze,

Thanks for your message!

Have a nice day!

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.