The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

Filter by custom fields

Topic prefix

AI Assistant
Get aggregated rati...
 
Notifications
Clear all

Get aggregated rating for a post

8 Posts
2 Users
0 Reactions
2,128 Views
(@zoker)
Posts: 22
Eminent Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 
[#2682]

Hello there,

I have this kind of article rating for a custom post type:

image
image

Now I need a php function, that returns me the aggregated rating from all three rating fields for all ratings for one specific post object. 

So something like one rating for the whole post. 

Example two ratings for one post:

  1. Design: 2/5, Usability: 3/5, Speed: 5/5 (avg. 3/5)
  2. Design: 5/5, Usability: 5/5, Speed: 5/5 (avg. 5/5)

So the overall rating for this post would be 4/5.

Something similar to the Aggregate Rating used for the Google schemas.

So I suppose since you need this value for the Google Schema, there is a function, that returns me the rating value (like post_rating( $post ) or something).

 

Thanks you very much!

Regards,

Florian


 
Posted : 30/07/2021 10:33 pm
Asti
 Asti
(@asti)
Posts: 8257
Illustrious Member Support
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

You should use the same wpdiscuz_rating_schema hook and make the customization yourself. 


In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.

 
Posted : 31/07/2021 1:18 pm
(@zoker)
Posts: 22
Eminent Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

But how can I get the rating value on any page for a specific post? 

For example using a shortcode to display the rating of post with the id 123.

Because the schema filter only defines how the output schema in the source code will look like, right? 


 
Posted : 31/07/2021 5:16 pm
(@zoker)
Posts: 22
Eminent Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Or to say it in other words: I want to use the ratingValue (within the schema)

Or to even more precise: I want the $avarage value from this function:

image

 
Posted : 31/07/2021 9:26 pm
Asti
 Asti
(@asti)
Posts: 8257
Illustrious Member Support
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@zoker,

For example using a shortcode to display the rating of post with the id 123.

You can add the post_id attribute in the shortcode: 

[ wpdrating metakey="all" show-lable=true show-count=true show-average=true itemprop=true post_id="123" ] 

It'll display the average rating(included all rating fields) for the current post.  


In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.

 
Posted : 02/08/2021 3:18 pm
(@zoker)
Posts: 22
Eminent Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Unfortunately I can't see the shortcode :/

image

 
Posted : 02/08/2021 3:46 pm
Asti
 Asti
(@asti)
Posts: 8257
Illustrious Member Support
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Please check it again.  


In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.

 
Posted : 02/08/2021 4:29 pm
(@zoker)
Posts: 22
Eminent Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@asti Thanks for the provided shortcode, but with that I only get something like this:

image

When you have a look at my site, you can see, that on the frontpage, some items have a rating (the 4.0 in the top left corner):

image

That's what I need. So I just need the value in decimal form, like 3.5 / 2.9 / 5.0 etc. 

And for that I don't that this shortcode is not suitable. 


 
Posted : 02/08/2021 5:00 pm