Site icon WP Smith

How to Customize the Genesis Comment Form

Here's how to customize the Genesis Comment form.
[php]add_filter('genesis_comment_form_args', 'custom_genesis_comment_form_args');
/**
* Modify comments
*/
function custom_genesis_comment_form_args($args) {
$args = array (
'title_reply' => __( 'Leave a Comment', 'genesis' ), //default='Speak Your Mind'; WordPress deafult: __( 'Leave a Reply' )
'label_submit' => __( 'Submit Comment', 'genesis' ), //default='Post Comment'
'title_reply_to' => __( 'Reply Title', 'genesis' ), //Default: __( 'Leave a Reply to %s' )
'cancel_reply_link' => __( 'Cancel', 'genesis' ) //Default: __( 'Cancel reply' )
);
return $args;
}[/php]

To Change the Reply Link Text or the Login to Comment Text, add this to your functions.php, which is largely borrowed from WordPress core so it maintains the same functionality.
[php]add_filter('comment_reply_link', 'custom_comment_reply_link');
function custom_comment_reply_link($args) {
global $user_ID;

$args = array(
'reply_text' => __('Debate'), // WordPress/Genesis Default: Reply
'login_text' => __('Please Log in First')); // WordPress/Genesis Default: Log in to leave a comment

$defaults = array('add_below' => 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply'),
'login_text' => __('Log in to Reply'), 'depth' => 0, 'before' => '', 'after' => '');

$args = wp_parse_args($args, $defaults);

extract($args, EXTR_SKIP);

$comment = get_comment($comment);
if ( empty($post) )
$post = $comment->comment_post_ID;
$post = get_post($post);

if ( !comments_open($post->ID) )
return false;

$link = '';

if ( get_option('comment_registration') && !$user_ID )
$link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $login_text . '</a>';
else
$link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm("$add_below-$comment->comment_ID", "$comment->comment_ID", "$respond_id", "$post->ID")'>$reply_text</a>";
return $link;
}[/php]

You can edit the comment form (to add WILL NOTE BE PUBLISHED beside the Email, etc.) with this code in your [I]functions.php[/I] file.

[php]add_filter('genesis_comment_form_args','custom_email_note');
function custom_email_note() {
$args = array(
'fields' => array(
'author' => '<p class="comment-form-author">' .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" tabindex="1"' . $aria_req . ' />' .
'<label for="author">' . __( 'Name', 'genesis' ) . '</label> ' .
( $req ? '<span class="required">*</span>' : '' ) .
'</p><!-- #form-section-author .form-section -->',

'email' => '<p class="comment-form-email">' .
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" tabindex="2"' . $aria_req . ' />' .
'<label for="email">' . __( 'Email: Not Published', 'genesis' ) . '</label> ' .
( $req ? '<span class="required">*</span>' : '' ) .
'</p><!-- #form-section-email .form-section -->',

'url' => '<p class="comment-form-url">' .
'<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" tabindex="3" />' .
'<label for="url">' . __( 'Website', 'genesis' ) . '</label>' .
'</p><!-- #form-section-url .form-section -->'
),

'comment_field' => '<p class="comment-form-comment">' .
'<textarea id="comment" name="comment" cols="45" rows="8" tabindex="4" aria-required="true"></textarea>' .
'</p><!-- #form-section-comment .form-section -->',

'title_reply' => __( 'Speak Your Mind', 'genesis' ),

'comment_notes_before' => '',

'comment_notes_after' => '',
);
return $args;
}[/php]