Support Center

Frequently asked questions and support documentation for RatingWidget.

  • >
  • Is there any PHP shortcodes I can use for my custom posts...?

Is there any PHP shortcodes I can use for my custom posts templates?

We created several custom PHP shortcodes to make it easy for you adding RatingWidget into your custom templates or even if you want to customize the exact location of the ratings in your pages.

Here are the shortcodes:

  • Output post / page / comment rating:
    function rw_the_post_rating($postID = false, $class = 'blog-post', $schema = false);
  • Return post / page / comment rating:
    function rw_get_post_rating($postID = false, $class = 'blog-post', $schema = false);
  • Output user rating:
    function rw_the_user_rating($userID = false);
  • Return user rating:
    function rw_get_user_rating($userID = false);

Usage example:

<?php rw_the_post_rating(14, 'front-post'); ?>

Params:

  • $postID – The post id. Defaults to current’s loop post id.
  • $class - Rating class/type. For front page posts use ‘front-post’, for posts use ‘blog-post’, for pages user ‘page’, for comments use ‘comment’.
  • $schema - If TRUE, add Rich-Snippets schema.org metadata (only for Professional customers).
  • $userID - User ID. Defaults to current’s loop user.

You can find the shortcodes implementation in /rating-widget/lib/rw-shortcodes.php

Leave a Comment

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>