Disqus評論是WordPress第三方留言外掛,現時也有很多個人或大型網站所使用的評論功能,不過!如果你的博客(Blog)或網站,並不是那麼多訪客留言,這樣建議Disqus加上顯示/隱藏的開關按鈕。
當瀏覽者想回文的時候,只要點擊開關按鈕,才載入Disqus評論。
打開主題目錄,修改「single.php」文件。
加入以下代碼:
<div id="mo_disqus_onclick">開關 :-) 留言板</div>
<div id="hidden-wrapper-div" style="display:none">
<div id="disqus_thread"></div>
</div>
打開主題目錄,修改「footer.php」文件。
加載JQuery庫:
<script type="text/javascript">
$j=jQuery.noConflict();
$j(document).ready(function() {
$j('#mo_disqus_onclick').on('click', function(){ // click event of the show comments button
var disqus_shortname = '請填入ShortName'; // Enter your disqus user name
// ajax request to load the disqus javascript
$j.ajax({
type: "GET",
url: "http://" + disqus_shortname + ".disqus.com/embed.js",
dataType: "script",
cache: true
});
$j('#hidden-wrapper-div').toggle(); // remove the show comments button
});
});
</script>
完成...
如果!博客的主題欠缺Jquery庫,你可以調用官方的Jquery CDN URL 請按此去!
什麼是ShortName!?
請按此處查看Disqus Shortname 教學...
原文: 請輕輕地按!
預覽效果Demo▼