Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] Comments using Sections

Home Forums Support Comments using Sections

  • This topic has 14 replies, 6 voices, and was last updated 1 year ago by David.
Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #325275
    Phil

    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

    GeneratePress 1.3.46
    #325307
    Leo
    Staff
    Customer Support

    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.

    #325318
    Phil

    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.

    #325319
    Leo
    Staff
    Customer Support

    I’ll make sure he sees the request 🙂

    Glad you are enjoying GP!

    #325331
    Phil

    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

    #325339
    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

    #325352
    Leo
    Staff
    Customer Support

    Awesome job! Thanks for sharing! I’m sure other users will find it helpful 🙂

    #655377
    Alexander

    Any update about this issue ?

    #655858
    Tom
    Lead Developer
    Lead Developer

    This likely isn’t something that will be added to the plugin, but the solution Phil mentioned above is great 🙂

    #858091
    David

    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:

    <?php echo dt_get_comments_template_shortcode(); ?>

    =========================
    I tried a few different variations but no luck. For example, remove echo, remove () however no luck.

    Thanks,
    David

    #858505
    Tom
    Lead Developer
    Lead Developer

    Hey David,

    With that function added, you can just add this shortcode to one of your Sections:

    [dt_get_comments_template]

    #858533
    David

    Hey Tom,

    Thanks for that. It worked a treat.

    Thanks,
    David

    #858843
    Tom
    Lead Developer
    Lead Developer
    #1057459
    Jeff

    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.

    #1057958
    David

    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

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.