How to Add Disqus if Comments are Closed in WordPress?


WordPress has inhouse comment system. The commenting text is part of the article text and thus can be indexed by search engines. However, the WP blogging commenting system is volunrable to spams and anti-spam comment plugins should be in place to prevent flooding spams.

Cloudflare provides cache-everything but this will make comment unusable if the comments are open unless you use third party commenting system e.g. disqus or make commenting ajax. We can modify the comments.php template to allow third party disqus commenting system if the comments are closed.

Edit the comments.php in child theme and add the elseif section on condition checking comments are open.

add-disqus-if-comments-closed How to Add Disqus if Comments are Closed in Wordpress? php wordpress

add-disqus-if-comments-closed

Third party plugins are easy to activate/deactivate. The comments can be managed separately without affecting the wordpress stability. However, the texts are not seen by search engines and thus not indexable.

For disqus to work properly, you have to set the variable this.page.url and this.page.identifier correctly. The page url can be obtained via WordPress API get_permalink() and the identifier is just an unique string i.e. MD5 hash. You could also use Javascript windows.location.href to obtain the current page URL.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
331 words
Last Post: The PHP Bing Wallpaper Bot Crawler
Next Post: What is R1Soft Continuous Data Protection?

The Permanent URL is: How to Add Disqus if Comments are Closed in WordPress?

Leave a Reply