WordPress Comment Form Widget


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. class wpe_comment_widget extends WP_Widget {
  3. function wpe_comment_widget() {
  4. $widget_ops = array('classname' => 'wpe_widget_comments', 'description' => __( 'Your comments and commentform', 'your_textdomain') );
  5. $this->WP_Widget('wpe-comment-widget', __('WPE Comments', 'your_textdomain'), $widget_ops);
  6. }
  7. function widget($args, $instance) {
  8. if(is_single()) {
  9. extract($args);
  10. global $post;
  11. echo $before_widget;
  12. comments_template();
  13. echo $after_widget;
  14. }
  15. }
  16. function update($new_instance, $old_instance) {
  17. $instance = $old_instance;
  18. return $instance;
  19. }
  20. function form($instance) {
  21. ?>
  22. <p><?php _e('This widget will only be displayed in single view.', 'your_textdomain'); ?></p>
  23. <?php
  24. }
  25. }
  26. register_widget('wpe_comment_widget');
  27. ?>

URL: http://wpengineer.com/1875/advent-calendar-24-days-tips-and-tricks-each-day-today-wordpress-comment-form-widget/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.