wpDiscuz Shortcodes

Below, you’ll find a detailed guide on how to add the Comments – wpDiscuz 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 Comments – wpDiscuz Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Comments – wpDiscuz Plugin and the shortcodes it provides:

Plugin Icon
Comments – wpDiscuz

"Comments – wpDiscuz is a revolutionary WordPress plugin that enhances your website's comments section. It offers real-time comment updates, inline commenting, and improved user interaction."

★★★★☆ (548) Active Installs: 80000+ Tested with: 6.2.3 PHP Version: false
Included Shortcodes:
  • [wpdiscuz_feedback]
  • [wpdrating]

wpDiscuz [wpdiscuz_feedback] Shortcode

The wpDiscuz Feedback Shortcode is designed to display a feedback form on a WordPress post. It checks if comments are enabled and if the user can see them. The shortcode also allows customization of the form’s ID and question, and whether it appears opened or closed. It generates an SVG icon and a count of comments, which can be moderated. Shortcode: [feedbackShortcode] The form displays the question and a close button, and it can be styled as ‘opened’ or ‘closed’. It creates an interactive user experience.

Shortcode: [wpdiscuz_feedback]


Here is a list of all possible wpdiscuz_feedback shortcode parameters and attributes:

  • id – Unique identifier for the specific feedback form.
  • question – The question to be displayed in the feedback form.
  • opened – Determines if the feedback form is opened (1) or closed (0) by default.

Examples and Usage

Basic example – A shortcode to display a feedback form using the form’s unique ID

[wpdiscuz_feedback id="123" /]

Advanced examples

Displaying a feedback form by referencing both ID and question. The form will first try to load by ID, but if not found, it will try to load by question.

[wpdiscuz_feedback id="123" question="How was your experience with us?" /]

Displaying a feedback form by referencing ID, question, and the opened status. If the opened status is set to 1, the form will appear as open by default.

[wpdiscuz_feedback id="123" question="How was your experience with us?" opened="1" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [WPDISCUZ_FEEDBACK_SHORTCODE] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode(self::WPDISCUZ_FEEDBACK_SHORTCODE, [&$this, "feedbackShortcode"]);

Shortcode PHP function:

function feedbackShortcode($atts, $content = "") {
        global $post;
        if ($this->isWpdiscuzLoaded && comments_open($post->ID) && apply_filters("wpdiscuz_enable_feedback_shortcode_button", true) && $this->form->isUserCanSeeComments(WpdiscuzHelper::getCurrentUser(), $post->ID)) {
            $atts = shortcode_atts([
                "id" => "",
                "question" => "",
                "opened" => 0
                    ], $atts, self::WPDISCUZ_FEEDBACK_SHORTCODE);
            if ($atts["id"] && $atts["question"] && ($inline_form = $this->dbManager->getFeedbackFormByUid($post->ID, $atts["id"]))) {
                $content = "<div class='wpd-inline-shortcode wpd-inline-" . ($inline_form->opened && $this->form->isUserCanComment(WpdiscuzHelper::getCurrentUser(), $post->ID) ? "opened" : "closed") . "' id='wpd-inline-" . $inline_form->id . "'>" . html_entity_decode($content);
                $content .= "<div class='wpd-inline-icon-wrapper'>";
                $content .= "<svg class='wpd-inline-icon" . ($this->options->inline["inlineFeedbackAttractionType"] === "blink" ? " wpd-ignored" : "") . "' xmlns='https://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path class='wpd-inline-icon-first' d='M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z'/><path class='wpd-inline-icon-second' d='M0 0h24v24H0z' /></svg>";
                $args = [
                    "count" => true,
                    "status" => !$this->options->wp["isPaginate"] && current_user_can("moderate_comments") ? "all" : "approve",
                    "meta_query" => [
                            "key" => self::META_KEY_FEEDBACK_FORM_ID,
                            "value" => $inline_form->id,
                            "compare" => "=",
                $count = get_comments($args);
                $content .= "<div class='wpd-inline-icon-count" . esc_attr($count ? " wpd-has-comments" : "") . "'>" . esc_html($count) . "</div>";
                $content .= "<div class='wpd-inline-form-wrapper'>";
                $content .= "<div class='wpd-inline-form-question'>" . esc_html($inline_form->question);
                $content .= "<span class='wpd-inline-form-close'><a href='#'>x</a></span>";
                $content .= "</div>";
                $content .= "</div>";
                $content .= "</div>";
                $content .= "</div>";

        return $content;

Code file location:


wpDiscuz [wpdrating] Shortcode

The wpDiscuz plugin shortcode [wpdrating] allows for the display and customization of post ratings. It enables the adjustment of rating labels, averages, and the use of schema markups. This shortcode fetches the post’s rating data and generates HTML to display it. It also handles RTL languages and enqueues the relevant styles. The shortcode supports customization for whether to show labels and averages, and which post’s ratings to display.

Shortcode: [wpdrating]


Here is a list of all possible wpdrating shortcode parameters and attributes:

  • metakey – Specifies the meta key for the rating
  • show-label – Controls the visibility of the rating label
  • show-lable – Seems to be a typo, should be ‘show-label’
  • show-average – Determines whether to display the average rating
  • itemprop – Enables or disables the post rating schema
  • post_id – Specifies the ID of the post to get ratings from
  • postid – Another parameter to specify the post ID

Examples and Usage

Basic example – Display the ratings of a specific post by using its post ID.

[wpdrating post_id=42 /]

Advanced examples

Display ratings for a specific post, but only show the average rating, not the label.

[wpdrating post_id=42 show-label=false /]

Display ratings for a specific post, with the Schema.org markup enabled. This could improve SEO by providing structured data to search engines.

[wpdrating post_id=42 itemprop=true /]

Display only a specific rating field for a post. This could be useful if you have multiple rating fields and want to display them separately.

[wpdrating post_id=42 metakey="field_key" /]

Display ratings for a specific post, but hide the label and average. This could be useful if you want to provide a minimalistic rating display.

[wpdrating post_id=42 show-label=false show-average=false /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdrating] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( "wpdrating", [ &$this->form, "getRatingMetaHtml" ] );

Shortcode PHP function:

function getRatingMetaHtml($atts = []) {
        $html = "";
        $atts = shortcode_atts([
            "metakey" => "all",
            "show-label" => true,
            "show-lable" => true,
            "show-average" => true,
            "itemprop" => !!$this->wpdOptions->rating["enablePostRatingSchema"],
            "post_id" => null,
            "postid" => null,
                ], $atts);
        if (!$atts["postid"]) {
            if ($atts["post_id"]) {
                $post = get_post($atts["post_id"]);
            } else {
                global $post;
            if (!empty($post->ID)) {
                $atts["postid"] = $post->ID;
                $wpdiscuz = wpDiscuz();
                $form = $wpdiscuz->wpdiscuzForm->getForm($post->ID);
                if (is_rtl()) {
                } else {
                $html = $form->getRatingMetaHtml($atts);
                global $post;
                $form = $wpdiscuz->wpdiscuzForm->getForm($post->ID);

                return $html;
        } else {
            $post = get_post($atts["postid"]);
            if ($this->ratingsExists && ( ( $this->wpdOptions->rating["ratingCssOnNoneSingular"] && !is_singular() ) || is_singular() )) {
                $ratingList = [];
                foreach (array_unique($this->ratingsFieldsKey) as $key => $field) {
                    $avg = floatval(get_post_meta($post->ID, wpdFormConst::WPDISCUZ_RATING_SEPARATE_AVG . $field, true));
                    $c = intval(get_post_meta($post->ID, wpdFormConst::WPDISCUZ_RATING_SEPARATE_COUNT . $field, true));
                    $ratingList[$field]["average"] = $avg ? $avg : 0;
                    $ratingList[$field]["count"] = $c ? $c : 0;
                if ($ratingList) {
                    $atts["show-label"] = filter_var($atts['show-label'], FILTER_VALIDATE_BOOLEAN);
                    if (!filter_var($atts['show-lable'], FILTER_VALIDATE_BOOLEAN)) {
                        $atts["show-label"] = false;
                    $html .= "<div class='wpdiscuz-post-rating-wrap wpd-custom-field'>";
                    if (!isset($atts["metakey"]) || $atts["metakey"] === "" || $atts["metakey"] === "all") {
                        foreach ($ratingList as $key => $value) {
                            $html .= $this->getSingleRatingHtml($key, $value, $atts);
                        if ($atts["itemprop"]) {
                            $html .= $this->getRatingSchema($atts["metakey"], $ratingList, $atts["postid"]);
                    } else {
                        $html .= $this->getSingleRatingHtml($atts["metakey"], $ratingList[$atts["metakey"]], $atts);
                        if ($atts["itemprop"] && $ratingList[$atts["metakey"]]["count"]) {
                            $html .= $this->getRatingSchema($atts["metakey"], $ratingList, $atts["postid"]);
                    $html .= "</div>";

        return $html;

Code file location:



Now that you’ve learned how to embed the Comments – wpDiscuz 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

Your email address will not be published. Required fields are marked *