Below, you’ll find a detailed guide on how to add the Rate my Post – WP Rating System Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Rate my Post – WP Rating System Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Rate my Post – WP Rating System Plugin and the shortcodes it provides:
"Rate my Post – WP Rating System is a dynamic WordPress plugin. It allows users to rate your posts, providing valuable feedback and engagement. Perfect for blogs and review sites."
- [ratemypost]
- [ratemypost-result]
Rate my Post [ratemypost] Shortcode
The Rate-My-Post shortcode is a versatile tool that allows users to rate posts. This shortcode enqueues the reCAPTCHA script if enabled, then renders the rating widget for a specific post ID. It’s an effective way to gauge user feedback.
Shortcode: [ratemypost]
Parameters
Here is a list of all possible ratemypost shortcode parameters and attributes:
id
– Specifies the unique ID of the post for rating
Examples and Usage
Basic example – Show the rating widget for a specific post using its ID.
[ratemypost id=5 /]
Under the title ‘Advanced examples’:
Display the rating widget for a specific post using its ID and include the recaptcha script for added security.
[ratemypost id=5 recaptcha=true /]
Note: The ‘recaptcha’ parameter in the advanced example is a hypothetical parameter. It’s not included in the provided PHP function. However, it’s used here to illustrate how an advanced parameter might be used in the shortcode. Always refer to the actual documentation of the plugin to know what parameters are available and how to use them.
PHP Function Code
In case you have difficulties debugging what causing issues with [ratemypost]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ratemypost', array( $this, 'rating_widget_shortcode' ) );
Shortcode PHP function:
function rating_widget_shortcode( $atts ) {
// attributes
$info = shortcode_atts( array(
'id' => false,
), $atts );
// enqueue recaptcha
if ( $this->do_recaptcha() === 2 ) {
wp_enqueue_script( 'rmp-recaptcha' );
}
// output the rating widget
return $this->get_the_rating_widget( $info['id'] );
}
Code file location:
rate-my-post/rate-my-post/public/class-rate-my-post-public.php
Rate my Post [ratemypost-result] Shortcode
The Rate-My-Post shortcode is a tool that generates a results widget for a specific post. It uses the post’s ID as an attribute to display the ratings. This shortcode calls the ‘result_widget_shortcode’ function, which retrieves the post’s ID and outputs the associated ratings.
Shortcode: [ratemypost-result]
Parameters
Here is a list of all possible ratemypost-result shortcode parameters and attributes:
id
– The unique identifier for the specific post rating.
Examples and Usage
Basic example – This shortcode is used to display the results widget of a specific post by referencing its ID.
[ratemypost-result id=3 /]
Advanced examples
Using the shortcode to display the results widget by referencing the ID. If the ID is not found, it will return a default message.
[ratemypost-result id=5 /]
Using the shortcode without an ID. In this case, the shortcode will return a default message since the ID is not specified.
[ratemypost-result /]
PHP Function Code
In case you have difficulties debugging what causing issues with [ratemypost-result]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ratemypost-result', array( $this, 'result_widget_shortcode' ) );
Shortcode PHP function:
function result_widget_shortcode( $atts ) {
$info = shortcode_atts( array(
'id' => false,
), $atts );
// output the results widget
return $this->get_the_results_widget( $info['id'] );
}
Code file location:
rate-my-post/rate-my-post/public/class-rate-my-post-public.php
Conclusion
Now that you’ve learned how to embed the Rate my Post – WP Rating System Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply