Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
<?php
/*
 Plugin Name: My 1st Widget
 Plugin URI: http://example.com
 Description: Add my widget to theme
 Version: 1.0
 Author: example
 license: none
 */

class my_1st_widget extends WP_Widget{
    function __construct(){
        parent::__construct(false, $name = __('My 1st Widget'));
    }
    function form(){

    }
    function update(){

    }
    function widget($args, $instance){
        ?>
        <div class="widget_comments">
            <h2>Comments</h2>

            <?php
            $args = array('user_id' => '',
                'number' => 2
                 );

            $comments_query = new WP_Comment_Query;
            $comments = $comments_query->query($args);
              if ( $comments ) {

                 foreach ( $comments as $comment ) {

                      echo $comment->comment_content."<br>";<br>";
                    }
            } else {
                    echo 'No Comments!!!';
            }
        ?>

</div>
<?php
    }    
}
add_action('widgets_init', function(){
register_widget('my_1st_widget');})
?>
share|improve this question
    
What have your tried? –  fliespl Jul 22 '13 at 6:42
1  
Please explain your problem better. –  toscho Jul 22 '13 at 7:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.