Show rating in search results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Show rating in search results

This topic contains 9 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 years, 10 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #14385
    Jaime
    Jaime
    Participant

    Hi there!

    first of all this plugin and its documentation is just amazing!! Really big congrats for all the effort you have put in there.

    now to my question..
    I am using the plugin in one my sites to search through different blog posts. My blog posts can be rated through a really simple plugin in my website. I was wondering if it’s somehow possible to show the rating (as a number) on the content description of the search results? I have managed to get the custom fields shown as described in your plugin documentation.. but I haven’t managed a way to get the rating of the posts shown in the search results? It would be awesome to be able to that! 🙂

    Thank you very much for your help in advance!

    To see the page you will have to login first with the login details posted. The site is still in maintenance mode.

    Cheers,
    Jaime

    #14386
    Jaime
    Jaime
    Participant

    P.S.: I managed before to include the average rating in the single blog post by calling the following function:
    “<?php echo get_post_meta(get_the_ID(), ‘ratings_average’, true ); ?>” maybe there is a way to call it too?

    #14388
    Jaime
    Jaime
    Participant

    I am a bit creative today :). Maybe sorting the results based on the average score might be an option too?

    Thanks and sorry for the many questions..!

    Regards,
    Jaime

    #14402
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Jaime,

    Thank you very much for your kind words!

    It is actually possible, by using the advanced title and description fields, which allows displaying custom field values in search results, please check the following documentation: Advanced title & Description fields

    It is also possible to order the results by a custom field value: https://i.imgur.com/6m3mBpi.png

    I believe these are the options you are looking for.

    Best,
    Ernest Marcinko

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


    #14406
    Jaime
    Jaime
    Participant

    Hi Ernest,

    thank you very much for your fast reply. I read the documentation and it helped me really out to get some custom fields shown in the description field of the searched results posts. But I haven’t managed to get the average score shown..

    It is not a custom field which the user enters but more the score that different users give to a certain post (like reviews of a certain item?) I would like to show that score on the description text.

    I tried adding this to the advance field:
    <?php echo get_post_meta(get_the_ID(), ‘ratings_average’, true ); ?>

    which is the function I call to get score but that doesn’t seems to work.

    Do you may have any idea?

    Thanks

    Regards,
    Jaime

    Attachments:
    You must be logged in to view attached files.
    #14410
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Jaime,

    ..It is not a custom field which the user enters but more the score that different users give to a certain post (like reviews of a certain item?) I would like to show that score on the description text..

    From the code you are trying to use just actually gets the value of the rating, nothing else. The get_post_meta() function is to get a custom field value.

    However, from the screenshot, I see you have an error there. You cannot use any PHP code within those fields, so the line, where the rating is, should look like this:

    [<p><strong>Rating: {ratings_average}</strong></p>]

    ..and it will print out the numeric value of the rating. Ajax Search Pro will automatically call the get_post_meta() function for the field within the {..} brackets.

    Best,
    Ernest Marcinko

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


    #14417
    Jaime
    Jaime
    Participant

    Hi Ernest,

    perfect, it worked!
    This was exactly what I was looking for! Thank you very very much!! You really saved me out here :D.

    If I may ask one last Thing, do you know how to Display the number with two decimals? like: 4.00 instead of 4?

    Really big thanks here again.

    Cheers,
    Jaime

    #14499
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Jaime,

    Sorry for the late response, I was working a bit late on the new plugin release, fixing some issues.

    For this unfortunately a custom code will be needed, which will have to be placed into the functions.php file in the theme directory. Let me know if that is an okay solution for you, and I will construct the customization for you.

    Best,
    Ernest Marcinko

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


    #14503
    Jaime
    Jaime
    Participant

    Hi Ernest,

    no worries! I am glad I got such a great Response :).

    Don’t think that will be necessary I don’t want to cause you to much Trouble. I will be implementing other stuff on the Website soon and this would just have been a nice to have feature. Thank you very much for your great help. This is certainly the best plugin of my website and by FAR the best support ever had :).

    Thank you really much.

    Keep up the good work!

    Cheers,
    Jaime

    #14505
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you very much for your kind words Jaime, I really appreciate it 🙂

    I will leave this topic open for now, in case you change your mind. Just let me know and we will figure it out.

    Best,
    Ernest Marcinko

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


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

You must be logged in to reply to this topic.