Learnings from crashing wordpress on countless occasions!

woocommercelogo

Some woocommerce site-owners like to have a great commenting system in place of the reviews that come out-of-the-box with Woo-commerce.

WP Tuts+ has a great post on how to manually integrate Disqus with any page in wordpress. I’m going to start from there on how to extend those steps for Woocommerce -Disqus integration.

Assuming that you have already created your Disqus account and registed your site URL there and you also have a disqus shortname (for the purpose of this article, i’m taking the shortnme to be ‘my_awesome_shortname’)

Here is the code that you will need to copy into the functions.php of your theme :

function disqus_embed($disqus_shortname) {
    global $post;
    wp_enqueue_script('disqus_embed','http://'.$disqus_shortname.'.disqus.com/embed.js');
    echo '<div id="disqus_thread"></div>
    <script type="text/javascript">
        var disqus_shortname = "'.$disqus_shortname.'";
        var disqus_title = "'.$post->post_title.'";
        var disqus_url = "'.get_permalink($post->ID).'";
        var disqus_identifier = "'.$disqus_shortname.'-'.$post->ID.'";
    </script>';

You need to access the following file:So once you have copied this code into your functions.php, we are ready to call this function it anywhere we want the Disqus commeting system to appear.  Right now I really want it in my WooCommerce Reviews tab.

/wp-content/themes/your-theme/woocommerce/single-product-reviews.php

Just add this code here, after replacing ‘my_awesome_shortname’ with yout own disqus shortname:

<?php disqus_embed('my_awesome_shortname'); ?>

The recent woo-commerce 2 update has added a lot to a lot of people’s woes. Many themes are breaking and because the new update is a major release, not all file-names in the new version correspond to the older version. So a lot of tutorials and trouble-shooting material on the internet that has been written for Woo-commerce has become out-dated.

Being a wordpress novice, I do things by trail-n-error, and this has worked for me. I usually crash my site and servers over and over by these trials, just to trudge forward and get things going! If you face any issues, do let me know.

Tag Cloud