[Resolved] Comment Box Adjustment on Single Post

Home Forums Support Comment Box Adjustment on Single Post

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1464194
    Jatin

    Hi Guys,
    can you please advise how can i fix the comment box to a proper layout on a single post.

    View post on imgur.com

    Questions: 1) Can i move the comment box to my End of the Post after Categories
    2) if not how to adjust the left and right gaps as shown in the screenshot for the comment box. Thanks.

    #1464229
    Leo
    Staff
    Customer Support

    Hi there,

    Looks like you are using Comments โ€“ wpDiscuz so the question should be answered by their support.

    Here are some CSS to help to get you started:

    #comments {
        max-width: unset;
        margin: 0;
        padding: 0;
    }
    #wpdcom {
        margin-left: 0;
    }

    You can change the second unset to like 1000px to adjust the width.

    #1464819
    Jatin

    Thanks Leo. It works but there are Three questions on this:

    > The comment form is stretched, i wanted the same width but left aligned.
    > There is a gap from the in the container on top of the comment box. https://imgur.com/T5nPual
    > Is it possible to move it in the same container as my post.

    #1465886
    Leo
    Staff
    Customer Support

    Let’s try moving it first. I’m not sure if it will work as you are using a plugin but worth a shot.

    – Create a hook element:
    https://docs.generatepress.com/article/hooks-element-overview/

    – Add this as the content:

    <?php
    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;
    ?>

    Then choose the generate_after_content hook and check to execute PHP.

    Set the display rules to post > all posts.

    Let me know if this works or not. I tested and it works with the default comment form without a plugin.

    #1466175
    Jatin

    Yes it does work but shows two comment boxes now. Please check the link which i sent in the private info box.

    #1466182
    Leo
    Staff
    Customer Support

    Now add this to remove the default position:

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

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #1466597
    Jatin

    Thanks Leo, it worked perfectly file as needed. Only one concern here, I added your code in functions.php file and its not a child theme. So if i update my theme i might lose the changes what should i do here ?

    #1466892
    David
    Staff
    Customer Support

    Hi there,

    any code you add directly to the Parent Theme will be lost when the theme updates.
    You should use a Child Theme or add the code using the Code Snippets plugin:

    https://docs.generatepress.com/article/adding-php/

    #1467042
    Jatin

    Thanks David,

    Can I use Pluginception to create plugins and use that way or code snippets is better ? If pluginception is better then do I have to create a separate plugin for each piece of code or all of my code can go in one plugin.

    I have code snippets installed and when I add a code there is an option to run the code everywhere. How can I restrict it to run only for single posts.

    #1467559
    Leo
    Staff
    Customer Support

    Code Snippets is better and easier.

    How can I restrict it to run only for single posts.

    I don’t think the plugin offers this option.

    #1467634
    Jatin

    Thanks Leo

    #1467656
    Leo
    Staff
    Customer Support
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.