Site logo

Archived topic

How to Move Comments Area to Sidebar?

3 replies · Started by Doğukan on January 31, 2022

Viewing posts 1–4 of 4

I want to move comments area to left sidebar for just desktop version.
Can you help me for that?

Hi there,

try adding this PHP Snippet:

add_action( 'wp', function() {
    remove_action( 'generate_after_do_template_part', 'generate_do_comments_template', 15 );
} );

add_action( 'generate_after_left_sidebar_content', function() {
    if ( is_page() || is_single() ) {
        if ( comments_open() || '0' != get_comments_number() ) :
            /**
             * generate_before_comments_container hook.
             *
             * @since 2.1
             */
            do_action( 'generate_before_comments_container' );
            ?>

            <div class="comments-area">
                <?php comments_template(); ?>
            </div>

        <?php
        endif;
    }
} );

Not this will display after the left sidebar content and this will be on desktop and mobile. Theres no easy and stable way to only move it on destkop. We can help with some CSS to reorder it on Mobile if thats required.

Thank you for your help.
By the way, I am grateful for GeneratePress, you are my hero :)
This codes remove comments area but not move to left sidebar.

Do you have the Left Sidebar enabled on the posts ?

This archived topic is closed to new replies.