Support » Theme: Sequential » Comment Section on Main Page

  • I’d like for the ability to add a comment from the main blog page, rather than clicking on the Post first. I’ve searched forums and tried a few things with no luck. I think the suggestions didn’t specify exactly what pages to modify, so not sure if my changes were correct.

    If someone might be able pass along how to accomplish this, it will be appreciated.

    By the way, this would seem like a great addition to the theme options.

    -Brian

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @bdonova1!

    The challenge with this is that the comments_template() WordPress function (part of WordPress core, not the theme itself) specifically checks to make sure it is only on a single post or page before doing anything – it’s designed to not load on home or archive pages.

    That being said, you can manually add a from to add comments.

    The first step will be to set up a child theme.

    In that child theme, you’ll want to create a copy of the parent theme’s content.php file.

    At the end of that file, between the last two lines:

    </div><!-- .entry-content -->
    
    </article><!-- #post-## -->
    

    You can add the following:

    <?php
    // If comments are open, and this is the home page, display a comment form
    if ( ( comments_open()  && is_home() ) ):
    	comment_form();
    endif;
    ?>
    

    That will show a comment form on each post on your home page.

    It won’t list the comments, that would require a different function: wp_list_comments() (info).

    Personally, I’d recommend against listing comments on your home page, as long threads can make locating additional posts difficult – and setting up any kind of comment navigation may get a bit complex 🙂

    Thread Starter bdonova1

    (@bdonova1)

    Chad,

    Thanks for the response. It did work, though left a large amount of whitespace after the form. It is a bit more than what I intended, though I probably wasn’t clear enough.

    Seems like most themes already do this, and for some reason Sequential does not. I’d prefer a line like this at end of each post on main page:

    # of Comments Leave a Comment

    That would obviously link to the pertinent page. With the number of comments less important to me. But this is similar to what shows up on pages for individual posts, I’d just rather not expect users to know they need to click on the post title if they’d like to comment.

    I’ve attempted to find the code and place it in the main loop – but unsuccessfully so far. If you or anyone could point me to a solution, it would be appreciated. But I am learning more about WordPress as we go.

    Brian

    Ah, I’ve got you now – I misunderstood your goal before.

    Sounds like you were thinking more along the lines of the comments_popup_link() function:

    https://codex.wordpress.org/Function_Reference/comments_popup_link

    That will create a link to leave a comment, and let you specify the text for different comment states 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Comment Section on Main Page’ is closed to new replies.