The effects of alcohol on
sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Get aggregated rating for a post
✦ Summarize Topic
✦
✦
✦
AI is analyzing the discussion...
How-to and Troubleshooting
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
Show original
Translating...
Jul 30, 2021 10:33 pm
(@zoker)
Eminent Member
Joined: 4 years ago
Hello there,
I have this kind of article rating for a custom post type:
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:
Design: 2/5, Usability: 3/5, Speed: 5/5 (avg. 3/5)
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
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
Show original
Translating...
Jul 31, 2021 1:18 pm
(@asti)
Illustrious Member
Joined: 8 years ago
You should use the same wpdiscuz_rating_schema hook and make the customization yourself.
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
Show original
Translating...
Jul 31, 2021 5:16 pm
(@zoker)
Eminent Member
Joined: 4 years ago
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?
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
Show original
Translating...
Jul 31, 2021 9:26 pm
(@zoker)
Eminent Member
Joined: 4 years ago
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:
(@asti)
Joined: 8 years ago
Illustrious Member
Posts: 8210
Aug 02, 2021 3:18 pm
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
Show original
Translating...
@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.
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
Show original
Translating...
Aug 02, 2021 3:46 pm
(@zoker)
Eminent Member
Joined: 4 years ago
Unfortunately I can't see the shortcode :/
(@asti)
Joined: 8 years ago
Illustrious Member
Posts: 8210
Aug 02, 2021 4:29 pm
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
Show original
Translating...
(@zoker)
Joined: 4 years ago
Eminent Member
Posts: 22
Aug 02, 2021 5:00 pm
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
Show original
Translating...
@asti Thanks for the provided shortcode, but with that I only get something like this:
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):
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.