• Resolved actronab

    (@actronab)


    Hello!

    I’d like to add an info box to the blog’s comment form. I’m using a child theme based on the TRAVEL demo of OceanWP and I’d like to add the box after the submit button. However, I checked almost all filters and hooks I could find, but I cannot position it correctly.

    I tried this code, which positions the box between the big comment textarea and the input fields for name, email and url. However, I want to position it after these input fields and after the submit button at the very end.

    function code_of_conduct_box( $defaults ) {
      $defaults['comment_notes_after'] = '<div class="comment-reminder"><h4>Foobar</h4><p>Some text.</p></div>';
      return $defaults;
    }
    
    add_filter( 'comment_form_defaults', 'code_of_conduct_box' );

    I also tried other actions that placed the box correctly for initial comments. It I reply to an existing comment, however, the form elements move up and are displayed right beneath the input fields, whereas the info box was still inserted at the very end of ALL comments.

    How can I insert the box after the submit button for initial comments and replies?

    Any help is greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    You can use the OceanWP child theme to add the box to your desired location.

    Thread Starter actronab

    (@actronab)

    Ultimately, this did the trick for me:

    add_action( 'comment_form', 'code_of_conduct_box' );

    This adds the box to the very end of the form. In addition, some CSS styling is required to create a space between the submit button and the box. I added a margin-bottom: 20px; to the submit button and had to clear: both; in my box.

    • This reply was modified 7 years, 7 months ago by actronab.

    Glad to hear that you found a solution.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Add additional box after blog’s comment form’ is closed to new replies.