Tagged: comment form
-
AuthorPosts
-
November 7, 2014 at 6:41 pm #347857November 7, 2014 at 10:24 pm #347969
Hey Ralph12!
The code your looking for is on line 164 in the /enfold/comments.php template.
comment_form();
You can surround it with an if statement and do some kind of check there.
Regards,
Elliott- This reply was modified 9 years, 11 months ago by Elliott.
November 8, 2014 at 11:21 am #348103Hey Elliott!
Thank you for your suggestion! The only problem with modding comments.php, is that it wouldn’t be update-proof. But it seems to be the only way to specifically target the comment form itself.
I do have 2 solutions that can be made update-proof, by placing them in a custom functions file. But they seem to remove comment counts as well. But I’m going to share ’em anyway, as they might be of some use to someone else.
Solution 1
Can be used to close comments for certain posts:function close_comment_form( $open, $post_id ) { $post = get_post( $post_id ); if( $post->post_type == 'post' ) { return false; } return $open; } add_filter( 'comments_open', 'close_comment_form', 10 , 2 );
Solution 2
Can be used to hide the comment form viadisplay: none;
on CSS selector#HIDEcommentform
:function my_comment_form_defaults($defaults) { $defaults['id_form'] = 'HIDEcommentform'; return $defaults; } add_filter('comment_form_defaults', 'my_comment_form_defaults');
In case someone has a solution for specifically targeting the comment form itself, via an update-proof functions file, then I’d love to hear about it.
Thanks again,
Ralph
November 9, 2014 at 6:33 pm #348375Hi!
If you want to make it update proof then I would create a child theme and move the comments.php template into it.
Also, if your just wanting to remove the comment form on some posts then when you edit the post you can uncheck the “Allow comments” option. There is also an option for closing posts for future comments based on how old the post is in Dashboard > Settings > Discussion. This will create a “Comments are closed” text to display instead of the comment form but you can hide that with CSS if you wish.
Cheers!
Elliott- This reply was modified 9 years, 11 months ago by Elliott.
November 10, 2014 at 4:54 pm #348852Hi Elliott,
The reason I need to mod the comments part, is because of a special kind of post. I actually ended up creating a custom post type for this, which is actually way better than sticking to the standard WP post type. And I gave this custom post type its own file based on the original comments.php file. So now I can edit both the single-costum_post.php file plus the relating comments file, without touching Enfold’s core files. So it has pretty much the same result as a child theme, which is great!
Also, I noticed that when using a check resulting in comments_open() = false, the comment count is actually displayed when the comment count is greater than 0. So, in a comment count is greater than 0 situation, only the comment form will be hidden, while the comments and the comment count will be displayed. The reason I thought that not only the comment form was hidden but the comment count as well, is because I only tested in a zero comment situation. Had I tested a comments_open() function in a comment count is greater than 0 situation, only the comment form would have been hidden. I’m sorry for not figuring that out sooner!
Conclusion: Solution 1 is definitely suitable for hiding the comment form itself. And then, as per your suggestion, the “Comments are closed” text could be hidden using some CSS.
Thank you very much for your time and patience!
Kind regards,
Ralph
November 11, 2014 at 12:04 am #349116Hi!
Your welcome. Let us know if you have any other questions.
Best regards,
Elliott- This reply was modified 9 years, 11 months ago by Elliott.
-
AuthorPosts
- You must be logged in to reply to this topic.