How do I hide the WordPress comments form?

心已入冬 提交于 2019-12-22 18:36:20

问题


I have a plugin that enables Facebook commenting on WordPress. Users have requested a feature that will hide the default WordPress comments form on posts where Facebook commenting is enabled.

How do I go about hiding the WP comments form on the fly? I know I can comment out comment_form(); from the comments.php template, but I'd like to be able to hide/unhide it at the click on a button.

Does it have something to do with the comments_template filter?

The plugin's homepage is http://grahamswan.com/facebook-comments


回答1:


Wrap the form in a div and use this simple piece of jquery to show/hide the div.

<div class="comments">
<?php comment_form(); ?>
</div>

<a class="comment_switch">Show / Hide Comments</a>

.hidden{display:none;}

$("comment_switch").click(function () {
     $("comments").toggleClass("hidden")");
   });


来源:https://stackoverflow.com/questions/3090267/how-do-i-hide-the-wordpress-comments-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!