Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Add Star Rating to Search Results
- This topic has 7 replies, 2 voices, and was last updated 6 years ago by
Ernest Marcinko.
-
AuthorPosts
-
May 4, 2020 at 1:23 am #27065
uniedcom75
ParticipantI 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 #27083Ernest Marcinko
KeymasterHi,
Well, does that plugin have any shortcodes to place the ratings to the post content?
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.May 4, 2020 at 7:11 pm #27090uniedcom75
ParticipantThis 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 #27092Ernest Marcinko
KeymasterThank 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!
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; }May 9, 2020 at 7:36 pm #27209uniedcom75
ParticipantOkay 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
May 11, 2020 at 11:44 am #27216Ernest Marcinko
KeymasterWhoops, my bad. Try this variation instead.
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; }May 11, 2020 at 5:36 pm #27242uniedcom75
ParticipantThank 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
May 12, 2020 at 7:14 am #27252Ernest Marcinko
KeymasterSure. 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:
.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; } -
AuthorPosts
- You must be logged in to reply to this topic.