Tutorial on how to setup Disqus Comment system on Wordpress to load on demand.
Tutorial on how to setup Disqus Comment system on Wordpress to load on demandMost WordPress sites use Disqus as their commenting system. The easiest way to implement Disqus on your website is to use their plugin.
Since Disqus loads asynchronously, your web page load speeds are not affected. However, Disqus downloads required files to the user’s system, which adds the weight of posts/pages where you have implemented Disqus codes. This costs your users their valuable bandwidth.
There are numerous other posts on internet related to the topic. The one I liked the most is from Labnol. However, in his post he didn’t mention how to dynamically get post url, post ID etc. We bring you a code snippet that you can place in your theme’s “functions.php” file.
Place the below code in your theme’s “functions.php” file or your site-specific plugin. Remember to change the short name from “aneejian” to your Disqus short name - line highlighted in code
var disqus_shortname = "your disqus short name";
Place the below code where you want Disqus to load. This will show a link “Load Comments” where you have placed the code. Clicking the link will load comments.
You can place it in your theme’s “comments.php” file or “single.php” file or you can use a plugin that can insert codes to your post/pages.