Decent Comments Shortcode

Below, you’ll find a detailed guide on how to add the Decent Comments Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Decent Comments Plugin shortcode not to show or not to work correctly.

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

Plugin Icon
Decent Comments

"Decent Comments is a dynamic WordPress plugin that transforms the way you manage, display, and interact with comments on your website. Enhance user engagement and discussions with ease."

★★★★✩ (19) Active Installs: 3000+ Tested with: 6.1.4 PHP Version: 5.6.0
Included Shortcodes:
  • [decent-comments]

Decent Comments [decent-comments] Shortcode

The Decent Comments shortcode is a powerful tool that fetches and displays comments based on specified options. It uses the ‘decent_comments’ function to render comments. This function takes two parameters: ‘atts’, which represents user-defined attributes, and ‘content’. It then merges these attributes with the default ones and retrieves the comments accordingly.

Shortcode: [decent-comments]

Examples and Usage

Basic example – A simple usage of the decent-comments shortcode to display comments with default parameters.

[decent-comments /]

Advanced examples

Displaying the decent-comments shortcode with specific parameters. In this case, the parameters are number (to define the number of comments to display) and order (to define the order of comments).

[decent-comments number="5" order="desc" /]

Using the decent-comments shortcode to display comments with more complex parameters. Here, we are specifying the number of comments to display, the order of comments, and the post_id to display comments only from a specific post.

[decent-comments number="5" order="desc" post_id="10" /]

Utilizing the decent-comments shortcode to display comments with excerpt and avatar. This will display the comments with a short excerpt and the avatar of the commenter.

[decent-comments number="5" excerpt="true" avatar="true" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'decent-comments', array( 'Decent_Comments_Shortcode', 'decent_comments' ) );

Shortcode PHP function:

                    function decent_comments( $atts, $content = null ) {
		$options = shortcode_atts( Decent_Comments_Renderer::$defaults, $atts );
		return Decent_Comments_Renderer::get_comments( $options );
	}
                    

Code file location:

decent-comments/decent-comments/class-decent-comments-shortcode.php

Conclusion

Now that you’ve learned how to embed the Decent Comments Plugin shortcode, 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.

Comments

Leave a Reply

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