Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Add Star Rating to Search Results
This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko 3 years ago.
- AuthorPosts
- May 4, 2020 at 1:23 am #27065
I do not have FTP setup for the website if you need FTP access I will have to activate it.
I have a plugin called Rate my post and when you view the posts on the site it shows the start ratings in the post Title however when you do a search the results are not showing the Star Rating.
Can you assist with helping us get the Star Rating into the Search Results.
Thanks
May 4, 2020 at 2:49 pm #27083Hi,
Well, does that plugin have any shortcodes to place the ratings to the post content?
Best,
I can try to suggest a custom code, but there is a very high chance that it may not work at all, because there are significant differences between live results and the post pages.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 4, 2020 at 7:11 pm #27090This is the documentation for the ratings plugin.
https://blazzdev.com/documentation/rate-my-post-documentation/Maybe you can find something that works, that you can give us guidance on.
Thanks
May 5, 2020 at 8:34 am #27092Thank you very much, that actually helps a lot, I have found a usable shrotcode.
Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
Best,add_filter( 'asp_results', 'asp_filter_posts_add_rating', 10, 1 ); function asp_filter_posts_add_rating( $results ) { foreach ($results as $k => &$r ) { if ( isset($r->post_type) ) $r->content = "[ratemypost id='".$r->id."']" . '<br>' . $r->content; } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 9, 2020 at 7:36 pm #27209Okay I have added the code to functions.php file. Thank you for that.
Please see attached screenshot. But Basically it is displaying the shortcode rather than the ratings in the results.
Hopefully this can be fixed with not to much effort.
Thanks
Attachments:
You must be logged in to view attached files.May 11, 2020 at 11:44 am #27216Whoops, my bad. Try this variation instead.
Best,add_filter( 'asp_results', 'asp_filter_posts_add_rating', 10, 1 ); function asp_filter_posts_add_rating( $results ) { foreach ($results as $k => &$r ) { if ( isset($r->post_type) ) $r->content = do_shortcode("[ratemypost id='".$r->id."']") . '<br>' . $r->content; } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 11, 2020 at 5:36 pm #27242Thank you so much that worked.
Attached is a screenshot of the output.
I know it is not your plugin but is there a way to make the stars a little smaller in the results so it is not so over powering.
Thanks
Attachments:
You must be logged in to view attached files.May 12, 2020 at 7:14 am #27252Sure. I did a few CSS tweaks, this looks much better in my opinion: https://i.imgur.com/MUNqAyY.png
For that, use this custom CSS:
Best,.asp_w .rmp-widgets-container.rmp-wp-plugin.rmp-main-container.js-rmp-widgets-container { margin: 0; } .asp_w p.rmp-heading.rmp-heading--title { display: none; } .asp_w p.rmp-heading.rmp-heading--subtitle { display: none; } .asp_w i.js-rmp-rating-icon.rmp-icon.rmp-icon--ratings.rmp-icon--star { height: 11px; line-height: 11px; font-size: 11px; } .asp_w p.rmp-rating-widget__results.js-rmp-results { display: none; } .asp_w p.rmp-rating-widget__msg.js-rmp-msg { display: none; } .asp_w p.rmp-rating-widget__hover-text.js-rmp-hover-text { display: none; } .asp_res_text br { display: none; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.