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.

I would like the comments of a post and the comment box to appear in the sidebar.

How can I do that?

share|improve this question
2  
Why wouldn't it be possible? What have you tried? Did it work? If not, what didn't work as expected? –  Chip Bennett Jan 11 '13 at 16:44
3  
I replaced the rhetoric question with something slightly more constructive. @user25893: Welcome to WordPress Stack Exchange! Please read How to Ask before you ask the next question, that will help you getting better help. –  toscho Jan 11 '13 at 19:33
add comment

1 Answer

up vote 3 down vote accepted

Yes, this is possible and actually a nice idea.

Basically create a simple widget, and remove the calls to comments_template() from other parts of your theme.

Example:

add_action( 'widgets_init', array ( 'T5_Current_Comments_Widget', 'register' ) );

class T5_Current_Comments_Widget extends WP_Widget
{
    public function __construct()
    {
        parent::__construct( 't5_current_comments', 'Current Comments' );
    }

    public function widget( $args, $instance )
    {

        if ( ! is_singular() or post_password_required() )
            return;

        print '<style scoped>#commentform,#commentform *{max-width:100% !important}</style>';
        comments_template();

        if ( get_option( 'thread_comments' ) and comments_open( get_the_ID() ) )
            wp_enqueue_script( 'comment-reply' );

    }

    public static function register()
    {
        register_widget( __CLASS__ );
    }
}

Then drag this simple widget into a sidebar …

enter image description here

… and that’s all. You can read and write comments here now:

enter image description here

You should of course move the CSS to your real stylesheet.

share|improve this answer
    
Thank you so much! –  Maxwell Jan 12 '13 at 2:54
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.