Skip to content

Instantly share code, notes, and snippets.

@i-like-robots
Created August 21, 2012 10:01
Show Gist options
  • Save i-like-robots/3414127 to your computer and use it in GitHub Desktop.
Save i-like-robots/3414127 to your computer and use it in GitHub Desktop.
Wordpress custom comment form
<?php if ( comments_open() ) : ?>
<form action="<?php echo site_url('/wp-comments-post.php') ?>" method="post" id="comments">
<ul class="form-collection">
<?php if ( is_user_logged_in() ) : global $current_user; ?>
<li>
<span class="field-hint">Logged in as <?php echo $current_user->user_login ?></span>
</li>
<?php else : ?>
<li>
<label for="comment-author" class="field-label">Name</label>
<input type="text" name="author" id="comment-author" />
</li>
<li>
<label for="comment-email" class="field-label">Email</label>
<input type="email" name="email" id="comment-email" />
</li>
<?php endif ?>
<li>
<label for="comment-body" class="field-label">Comment</label>
<textarea name="comment" id="comment-body"></textarea>
</li>
<li class="button-field">
<input type="submit" name="submit" value="Post comment" />
<?php
comment_id_fields();
if ( current_user_can( 'unfiltered_html' ) )
{
wp_nonce_field( 'unfiltered-html-comment_' . get_the_ID(), '_wp_unfiltered_html_comment', false );
}
?>
</li>
</ul>
</form>
<?php else : ?>
<p class="nocomments">
Comments are closed for this article.
</p>
<?php endif ?>
@paykwik
Copy link

paykwik commented May 11, 2017

Hi nice sharing but i have bugged in a few places my site will check if it fit. https://www.paykasakartsatinal.gen.tr/

@mohammadnoori
Copy link

i have problem with your code in my site https://filmr.ir/hamrafigh-series-download/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment