Skip To Content

Getting your woocommerce reviews to work with disqus

Kevin Doherty

Creative Director

Date

May. 21, 2015

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() )

 

Read More

Read More About

Book with us

Let’s accomplish what you are looking for, our team of experts are here for you.

Let's work together

Warning: Working with our team may result in excessive creativity, uncontrollable 'aha' moments, and an addiction to perfect pixels. Please proceed with caution.