Find the WordPress comment form, how to edit comment_form function?

This article was written by in September 16, 2013, & may not be posted on other sites!
Original source url for this article: Find the WordPress comment form, how to edit comment_form function?

Find the comment form WordPress,
Wondering how to find the actual code for the comment form in WordPress? Do you need to edit the comment_form function? Comments.php will not help you since the actual code for the comment form is located somewhere else. WordPress has a default comment form function located in the core files. This means comments.php in your theme doesn’t contain the actual code for the comment form, only calling the comment_form(); -function. Functions.php only offers the comments-list code above the actual comment form.

The actual comments form code is located here: wp-includes > comment-template.php on line 1599 as the last function of this file, or you can also search for “function comment_form”.

NOTE: You should never edit the WordPress core-files. As soon as you update WordPress your changes may be deleted.

How to edit comment_form function in WordPress?

Well, you basically can’t. You can not make a copy of the comment-template.php and put it in your theme, nor put the function comment_form in your functions.php. But you can use jQuery to append, remove or alter elements and content to the comments form.

Find the comment form WordPress, how to edit comment_form function

If you want to add elements or content next to your WordPress comment form the example code below might be usefull. Save the file as comments.php and put it into your childtheme folder. This file was made for a childtheme with WordPress Twenty Twelve theme as parrent theme.

* The template for displaying Comments.
* Author Olivia Hoback
* @package WordPress
* @subpackage Twenty_Twelve
* @since Twenty Twelve 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() )

<div id="comments" class="comments-area clearfix">

<?php // You can start editing here -- including this comment! ?>

<?php if ( have_comments() ) : ?>
<h2 class="comments-title">
printf( _n( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'twentytwelve' ),
number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );

<ol class="commentlist">
<?php wp_list_comments( array( 'callback' => 'twentytwelve_comment', 'style' => 'ol' ) ); ?>
</ol><!-- .commentlist -->

<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
<nav id="comment-nav-below" class="navigation" role="navigation">
<h1 class="assistive-text section-heading"><?php _e( 'Comment navigation', 'twentytwelve' ); ?></h1>
<div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'twentytwelve' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'twentytwelve' ) ); ?></div>
<?php endif; // check for comment navigation ?>

/* If there are no comments and comments are closed, let's leave a note.
* But we only want the note on posts and pages that had comments in the first place.
if ( ! comments_open() && get_comments_number() ) : ?>
<p class="nocomments"><?php _e( 'Comments are closed.' , 'twentytwelve' ); ?></p>
<?php endif; ?>

<?php endif; // have_comments() ?>

<div style="width:70%;float:left;">
<?php comment_form(); ?>

<div id="your-content" style="width:30%;float:right;height:711px;background-color:#dbcee0;">
<!--Put your content here-->

</div><!-- #comments .comments-area -->

Spread the word


One thought on “Find the WordPress comment form, how to edit comment_form function?

  1. Johnc144

    There is visibly a bundle to realize about this. I assume you made certain nice points in features also.

Leave a Reply

Your email address will not be published. Required fields are marked *