Archived topic
Comments using Sections
14 replies · Started by Phil on May 28, 2017
I am a noob, so this is probably a dumb question.
How can I add a comments form when I have a post set up using "sections"? I like formating with this feature, but the sidebar widgets and comments do not show up.
Thanks,
Phil
Hi Phil,
Unfortunately comments aren't activated in Sections. See Tom's explanation here: https://generatepress.com/forums/topic/showing-comments-with-sections-add-on/
You could activate sidebar though: https://docs.generatepress.com/article/allow-sidebars-sections/
Let me know if this helps.
Thank you, Leo! I hope that Tom can find a way to make this work in the future. This is a slight setback, nonetheless GP is an awesome theme.
I'll make sure he sees the request :)
Glad you are enjoying GP!
Okay, so here is what I did to make it work....
I used the Code Snippets plugin to add a shortcode for the comments form, as described in this post on wpsites.net.
I then added the shortcode to a new section on the page. I'm not sure if it makes a difference, but I placed the shortcode in a div element. I mainly did this so that I can add CSS styles, if I want to.
Here is the finished product, if you want to see. https://ipninja.info/netmon/network-monitoring-solutions/
Thanks,
Phil
One more thing...
Just using the "comments_form" function does not provide all of the functionality, so I used "comments_template" instead. Works great!
Thanks,
Phil
Awesome job! Thanks for sharing! I'm sure other users will find it helpful :)
Any update about this issue ?
This likely isn't something that will be added to the plugin, but the solution Phil mentioned above is great :)
Would it be possible to get step by step instructions on how to implement Phil's solution?
I have tried it but I am missing something.
What I did:
I added the following code to my functions.php file: (okay, I know that this is not the smartest and best way to do this)
add_shortcode( 'dt_get_comments_template', 'dt_get_comments_template_shortcode' );
function dt_get_comments_template_shortcode() {
ob_start();
comments_template();
$cform = ob_get_contents();
ob_end_clean();
return $cform;
}
==========================
I have "quick edited" the page to "allow comments".
I open up the page in the WP editor, I notice that the "allow comments" is ticked and add a new section to the bottom and add the following code to it:
=========================
I tried a few different variations but no luck. For example, remove echo, remove () however no luck.
Thanks,
David
Hey David,
With that function added, you can just add this shortcode to one of your Sections:
[dt_get_comments_template]
Hey Tom,
Thanks for that. It worked a treat.
Thanks,
David
You're welcome :)
Hi All,
I'm pretty new to WordPress but I'm loving the GeneratePress theme and have been making some good progress with it. I'm still a newbie though so thanks in advance for your patience. :)
Like others on this thread, I'm having problems with getting Comments to work on a Page that has Sections enabled.
Here's what I did...
1. Installed the Code Snippets plug-in and added the following snippet.
add_shortcode( 'wpsites_comment_form', 'wpsites_comment_form_shortcode' );
function wpsites_comment_form_shortcode() {
ob_start();
comment_form();
$cform = ob_get_contents();
ob_end_clean();
return $cform;
}
2. On my page I created a new Section and added:
[wpsites_comment_form]
This seemed to work and the Comments form shows up on the page with fields:
- comment field
- name
- email
- website
- checkbox for "Save my name, email and website in this browser for the next time I comment"
The problem is, after submitting a couple test Comments and approving them on the back-end... they don't appear to show up anywhere on the page? Any ideas why?
Second question... Is it possible to customize the comment form and say, change the field order or remove the website field? I'm sure the answer is yes... but HOW?
Thanks,
Jeff
EDIT:
Problem number one solved! I updated my snippet to use the one David provided above:
[dt_get_comments_template] and added that to my page instead and the comments are now showing!
Still wondering how to customize the form fields though.
Hi Jeff,
Thrilled to hear that you got the first thing sorted.
A couple of years ago I wrote a blog post on how to remove the website field from the comments form.
You can read that article below.
https://djtrlm.com/in-wordpress-how-to-remove-website-url-from-comments/
Hope this helps,
Cheers,
David