Skip To Content

Getting your woocommerce reviews to work with disqus

Development

Kevin Doherty Creative Director

Disqus is our go-to for all comment moderation when theming our websites for clients. Without going into all the reasons why. I have only found one caveat of using it and I’d like to share a workaround that resolves the issue 🙂

The Problem

Disqus hijacks the native WordPress commenting system. More times than not this is acceptable and the way it should work. BUT when using an e-commerce solution like Woocommerce it too relies on the WordPress commenting system. To integrate it’s rating and reviews.

The Solution

We can add a simple filter to our themes functions.php file which will remove Disqus. Based on any Custom Post Type we’d like, in this case, ‘products’.

The Code

// Disable Disqus for the 'product' Custom Post Type
add_filter( 'comments_template' , 'block_disqus', 1 );
function block_disqus($file) {
if ( 'product' == get_post_type() )
remove_filter('comments_template', 'dsq_comments_template');
return $file;
}

If you’d like to disable disqus on another custom post type change:

if ( 'product' == get_post_type() ) 

to

if ( 'your custom post type name goes here' == get_post_type() )

 

One Reply to “Getting your woocommerce reviews to work with disqus”

Comments

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

Request a Quote

If you’re ready to change the trajectory of your business and
excited to partner with the right team to get the job done.

UP

© 2024 NVISION. All Rights Reserved.