Moving Captcha to BELOW comment text area
-
The Captcha form is appearing above the text area for the content, and I’d like to move it to below the text area (but still above the submit comment button). I don’t want to change the comments-template.php file since that is a core WordPress file. I’d like to change it in the comments.php file, but I must not be getting the language quite right, because I can’t get it to work. This is the current comments code (and arguments) I am using… Can you please advise as to what I need to add to this to move the location of the Captcha? Thank you.
<?php $comments_args = array( // change the title of send button 'label_submit'=>'Post Comment', // change the title of the reply section 'title_reply'=>'Leave a Comment', // remove "Text or HTML to be displayed after the set of comment fields" 'comment_notes_after' => '', // redefine your own textarea (the comment body) 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><br /><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', ); comment_form($comments_args); ?>
-
Hi,
We have received your query and it is now being processed. We will get back to you on this forum as soon as we can.
Regards,
BestWebSoft Support TeamHi lightfoot33,
It depends on the comments form. If the hook call by means of which captcha works (after_comment_field or something like this) is present in the file comments.php, you can change captcha positioning by moving this hook call.
Please find the file ‘comments.php’ in the theme and change position of the line
do_action( ‘comment_form_after_fields’ );
or any similar line – place it under the Submit button.Regards,
BestWebSoft Support TeamThe comments.php file (taken directly from the latest WordPress theme) has no such line. Can you please advise where and/or to exactly add this line of code you are suggesting?
<?php /** * The template for displaying comments * * The area of the page that contains both current comments * and the comment form. * * @package WordPress * @subpackage Twenty_Fifteen * @since Twenty Fifteen 1.0 */ /* * If the current post is protected by a password and * the visitor has not yet entered the password we will * return early without loading the comments. */ if ( post_password_required() ) { return; } ?> <div id="comments" class="comments-area"> <?php if ( have_comments() ) : ?> <h2 class="comments-title"> <?php printf( _nx( 'One thought on “%2$s”', '%1$s thoughts on “%2$s”', get_comments_number(), 'comments title', 'twentyfifteen' ), number_format_i18n( get_comments_number() ), get_the_title() ); ?> </h2> <?php twentyfifteen_comment_nav(); ?> <ol class="comment-list"> <?php wp_list_comments( array( 'style' => 'ol', 'short_ping' => true, 'avatar_size' => 56, ) ); ?> </ol><!-- .comment-list --> <?php twentyfifteen_comment_nav(); ?> <?php endif; // have_comments() ?> <?php // If comments are closed and there are comments, let's leave a little note, shall we? if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?> <p class="no-comments"><?php _e( 'Comments are closed.', 'twentyfifteen' ); ?></p> <?php endif; ?> <?php $comment_args = array( 'fields' => apply_filters( 'comment_form_default_fields', array( 'author' => '' . '<label for="author">' . __( 'Your Name:' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' />' . '<!-- #form-section-author .form-section -->', 'email' => '' . '<label for="email">' . __( 'Your Email:' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' />' . '<!-- #form-section-email .form-section -->', 'url' => '' ) ), 'comment_field' => '' . '<label for="comment">' . __( 'Comment:' ) . '</label>' . '<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>' . '<!-- #form-section-comment .form-section -->', 'comment_notes_after' => '', ); comment_form($comment_args); ?> </div><!-- .comments-area -->
Hi lightfoot33,
To move Google Captcha in the comments form, please change the location of the hook do_action( ‘comment_form_after_fields’ ); in /wp-includes/comment-template.php file.
Unfortunately, if the theme uses a standard comments form, the only wat to change the location of our captcha is to make changes to /wp-includes/comment-template.php file in WordPress core.
Regards,
BestWebSoft Support TeamThanks, but this doesn’t help much since changing core files in WordPress is really frowned upon by most WordPress developers.
It’s a shame there isn’t any other solution.
Hi,
We know that it is not recommended, but unfortunately, there is no other solution, since the comment form template is missing in your theme.
Regards,
BestWebSoft Support TeamI had to hack this with some CSS. I am using the default comment form and the captcha was showing up above the comment field.
This CSS puts the captcha below the comment field and above the submit button
#commentform { position: relative; } .gglcptch { position: absolute; bottom: 55px; } .form-submit { margin-top: 110px; }
Hi helmutwalker,
Unfortunately, we can’t guarantee that the solution you provided will work with all commentaries form, since they all have different structure.
Sincerely,
BestWebSoft Support TeamI am using a Genesis Theme.
Here is the contents of my comments.php file:
/**
* Genesis Framework.
*
* WARNING: This file is part of the core Genesis Framework. DO NOT edit this file under any circumstances.
* Please do all modifications in the form of a child theme.
*
* @package Genesis\Templates
* @author StudioPress
* @license GPL-2.0+
* @link https://my.studiopress.com/themes/genesis/
*/if ( ! empty( $_SERVER[‘SCRIPT_FILENAME’] ) && ‘comments.php’ === basename( $_SERVER[‘SCRIPT_FILENAME’] ) )
die ( ‘Please do not load this page directly. Thanks!’ );if ( post_password_required() ) {
printf( ‘<p class=”alert”>%s</p>’, __( ‘This post is password protected. Enter the password to view comments.’, ‘genesis’ ) );
return;
}do_action( ‘genesis_before_comments’ );
do_action( ‘genesis_comments’ );
do_action( ‘genesis_after_comments’ );do_action( ‘genesis_before_pings’ );
do_action( ‘genesis_pings’ );
do_action( ‘genesis_after_pings’ );do_action( ‘genesis_before_comment_form’ );
do_action( ‘genesis_comment_form’ );
do_action( ‘genesis_after_comment_form’ );I’m confused as to what to move. Are we supposed to add this line and if so where?
do_action( ‘comment_form_after_fields’ );Since StudioPress themes are by far the most popular. I’m always baffled as to why plugin devs don’t first make sure that their plugins work with the Genesis Framework before anything else. Your help is greatly appreciated.
Hi webauthor,
The hook
do_action( 'comment_form_after_fields' );
– https://developer.www.ads-software.com/reference/hooks/comment_form_after_fields/. According to the WordPress codex (https://codex.www.ads-software.com/) it’s a standard hook, which presents in the comments form template. This hook is absent in your “comments.php” file because of your custom theme and its structure. Please try to contact your theme developers and their support service with this problem.Sincerely,
BestWebSoft Support TeamHello. This is my comments file here, where do i edit? ( the button for verification is right underneath the submit button currently ). I dont mind editing other files if i really have to, but … simpler solution would be great.
<?php /** * Theme Name: SPECTRA - Responsive Music WordPress Theme * Theme Author: Mariusz Rek - Rascals Themes * Theme URI: https://rascals.eu/spectra * Author URI: https://rascals.eu * File: comments.php * ========================================================================================================================================= * * @package spectra * @since 1.0.0 */ ?> <!-- ############################# Comment section ############################# --> <section id="comments" class="comments-section"> <div class="section-sign"> <span class="icon icon-bubbles"></span> </div> <!-- container --> <div class="container"> <?php // protect password protected comments if ( post_password_required() ) : ?> <p class="comment-message"><?php _e( 'This post is password protected. Enter the password to view any comments.', SPECTRA_THEME ); ?></p> <?php return; endif; ?> <?php if ( have_comments() ) : ?> <h4 class="comments-title"><?php printf( _n( '1 comment on "%2$s"', '%1$s comments on "%2$s"', get_comments_number(), SPECTRA_THEME ), number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>', SPECTRA_THEME ); ?></h4> <div class="comments-container clearfix"> <ul class="comment-list"> <?php wp_list_comments( array( 'type' => 'all', 'short_ping' => true, 'callback'=> 'spectra_comments' ) ); ?> </ul> <nav class="comments-navigation" role="navigation"> <div class="nav-prev"><?php previous_comments_link(); ?></div> <div class="nav-next"><?php next_comments_link(); ?></div> </nav> </div> <?php else : // there are no comments so far ?> <?php if ( comments_open() ) : ?> <!-- If comments are open, but there are no comments. --> <p class="comment-message"><?php _e( 'Currently there are no comments related to this article. You have a special honor to be the first commenter. Thanks!', SPECTRA_THEME ); ?></p> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="comment-message"><?php _e( 'Comments are closed.', SPECTRA_THEME ); ?></p> <?php endif; ?> <?php endif; ?> <?php $fields = array(); function custom_fields( $fields ) { global $comment_author, $comment_author_email, $comment_author_url; $fields['author'] = '<div class="col-1-3"> <label for="author">' . __('Name (required)', SPECTRA_THEME ) . '</label> <input type="text" name="author" id="author" value="' . $comment_author . '" size="22" tabindex="1" required /> </div>'; $fields['email'] = '<div class="col-1-3"> <label for="email">' . __('Email (required)', SPECTRA_THEME ) . '</label> <input type="text" name="email" id="email" value="' . $comment_author_email . '" size="22" tabindex="2" required /> </div>'; $fields['url'] = '<div class="col-1-3 last"> <label for="url">' . __('Website URL', SPECTRA_THEME ) . '</label> <input type="text" name="url" id="url" value="' . $comment_author_url . '" size="22" tabindex="3" /> </div>'; return $fields; } add_filter('comment_form_default_fields', 'custom_fields'); $form_fields = array( 'fields' => apply_filters( 'comment_form_default_fields', $fields ), 'title_reply' => __('Join the discussion', SPECTRA_THEME), 'title_reply_to' => __('Leave a Reply.', SPECTRA_THEME), 'cancel_reply_link' => __('(Click here to cancel reply)', SPECTRA_THEME), 'comment_notes_before' => '', 'label_submit' => __('Post Comment', SPECTRA_THEME), 'comment_notes_after' => '<p class="form-allowed-tags">' . __('* Your email address will not be published.', SPECTRA_THEME) . '<br/>' . sprintf( __('You may use these HTML tags and attributes: %s', SPECTRA_THEME), ' <span>' . allowed_tags() . '</span>' ) . '</p>', 'comment_field' => '<div class="comment-field"> <label for="comment">' . __('Your Comment (required)', SPECTRA_THEME) . '</label> <textarea tabindex="4" rows="9" id="comment" name="comment" class="textarea" required></textarea> </div>' ); ?> <?php comment_form( $form_fields ); ?> </div> </section> <!-- /comments -->
actually I just fixed it with that CSS hack … Thanks helmutwalker!!!
I just had to adjust the parameters a bit.
Hi,
Thank you for message, we’re glad that you’ve found a solution.
In future, if you’ll have any questions, please contact us via our support forum to receive a quick reply (https://support.bestwebsoft.com/).
Sincerely,
BestWebSoft Support Teamhelmutwalker Man, It works great for me in Genesis Theme!
- The topic ‘Moving Captcha to BELOW comment text area’ is closed to new replies.