Add Star Rating to Search Results

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

 
Keymaster
1 year, 8 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #27065

    Participant

    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

    #27083

    Hi,

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #27090

    Participant

    This 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

    #27092

    Thank 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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #27209

    Participant

    Okay 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.
    #27216

    Whoops, 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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #27242

    Participant

    Thank 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.
    #27252

    Sure. 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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.