How To Add WPDisquz To Custom Locations With A Shortcode

By James LePage
 on January 7, 2021
Last modified on January 6th, 2022

How To Add WPDisquz To Custom Locations With A Shortcode

By James LePage
 on January 7, 2021
Last modified on January 6th, 2022

In this will guide, we're going to show you how to create a short code for the wpDiscuz, allowing you to custom position comments anywhere on your single post or custom post type. The wpDiscuz is a great tool for comment management on high traffic WordPress websites, and it's the one that we use on this blog. If you want to add it to a custom location on your WordPress website, creating a short code for wpDiscuz, and then placing that shortcode anywhere on the page is a great way to do that.

To create a shortcode for wpDiscuz, it's no different than creating a short code for the standard WordPress comments feature. The reason behind this is due to the fact that the wpDiscuz simply replaces the standard WordPress comments PHP with its own. Therefore, anywhere a normal WordPress comments section shows up on the site, the wpDiscuz will replace it with its own design and functionality.

So, to create a short code for wpDiscuz, all you need to do is paste in the following code, which is a direct copy of the code used to create a custom WordPress comments shortcode.

This code (source) should be added to your functions.PHP on your child theme, or by a code manager like Advanced Scripts (recommended method). It should be loaded in on “plugins loaded”.

 * Display the comment template with the [wpse_comments_template] 
 * shortcode on singular pages. 
 * @see
 add_shortcode( 'wpse_comments_template', function( $atts = array(), $content = '' )
    if( is_singular() && post_type_supports( get_post_type(), 'comments' ) )
        add_filter( 'comments_open',       'wpse_comments_open'   );
        add_filter( 'get_comments_number', 'wpse_comments_number' );
        return ob_get_clean();
    return '';
}, 10, 2 );

function wpse_comments_open( $open )
    remove_filter( current_filter(), __FUNCTION__ );
    return false;

function wpse_comments_number( $open )
    remove_filter( current_filter(), __FUNCTION__ );
    return 0;
}Code language: PHP (php)

Now, if you want to place your wpDiscuz comments section anywhere on your website, simply paste in the following short code, navigate to the front end, and see the comments section in the new position.

[wpse_comments_template] Code language: JSON / JSON with Comments (json)

TESTED WORKING JAN 2021 (Oxygen Builder, Elementor)

Subscribe & Share
If you liked this content, subscribe for our monthly roundup of WordPress news, website inspiration, exclusive deals and interesting articles.
Unsubscribe at any time. We do not spam and will never sell or share your email.
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
2 years ago

I tried this in Oxygen Builder and the comments do show up wherever the shortcode is placed. However, wpDiscuz still does not load on the backend or frontend. What do you mean when you say Working with Oxygen Builder? Is there another tutorial that gets wpDiscuz working with Oxygen?

2 years ago

Hello can i ask you a question. I used your code and workds fine but the bubble dissapeared.

Article By
James LePage
James LePage is the founder of Isotropic, a WordPress education company and digital agency. He is also the founder of, a venture backed startup bringing AI to WordPress creators.
We're looking for new authors. Explore Isotropic Jobs.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram