워드프레스 Unable to connect to the Disqus API servers
워드프레스에 댓글에 Disqus를 연동하려고 Disqus Comment System 플러그인을 설치하였는데.
플러그인 활성화후 아무리 로그인을 해도 자꾸만 Unable to connect to the Disqus API servers 라고 메세지가 나온다.
열뻗친다.!
검색해보니 사용하는 호스팅에서 disqus.com 이나 disqus.net 연결 80 포트를 호스팅에서 차단해서 일것이라고 한다.
이럴경우 플러그인 설치말고 직접 코드를 붙이는 작업을 하면 된다고 한다. 즉, Universal code로 하라는 말이다.
어렵지 않다. 하지만 사용하고 있는 테마에 적합하게 레이아웃 잡지 않으면 댓글이 겹쳐지거나 삐져나올것이다.
적용법을 간단히 정리해보자면
사용하는 테마에 comments.php 파일을 백업한후 그안에 내용을 아래것으로 복사한다.
<div id="comments"> <div class="post-comments group"> <div id="disqus_thread"></div> <script> /** * RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS. * LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables */ /* var disqus_config = function () { this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable }; */ (function() { // DON'T EDIT BELOW THIS LINE var d = document, s = d.createElement('script'); s.src = '//coolnixnet.disqus.com/embed.js'; s.setAttribute('data-timestamp', +new Date()); (d.head || d.body).appendChild(s); })(); </script> <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript> </div> </div>
그리고 footer.php 에 아래내용을 추가한다. </body> 끝나기전에
<script id="dsq-count-scr" src="//coolnixnet.disqus.com/count.js" async></script>
이렇게 해서 이 블로그에도 Disqus 댓글을 연동했다! 🙂
참고자료:
https://help.disqus.com/customer/portal/articles/1183281
https://coolnixnet.disqus.com/admin/universalcode/
Unable to connect to the Disqus API servers wordpress plugin