How to add comments on home page in wordpress?

I want to add a comments section in index.php of WordPress.

I added the following code:

Read More
<td align="left" valign="top">
    <?php $withcomments = 1;comments_template(); ?>
</td>

Comments are shown because of the above code, but when a user adds a comment on the index page, it redirects to a default post and also adds that comment to that default post.

Is it possible to make comments on the index page and also have them shown in the index page? If anyone can help me it will be appreciated.

Related posts

Leave a Reply

2 comments

  1. It depends a lot about how your theme is structured: loop is written in single.php file directly, or there is a loop file which is included in both single.php and index.php .

    Your homepage should be either home.php or index.php ( usually the second version ). If the loop is shared for both single post and index, you should find something like this:

    <?php // Load Comments template (on single post pages, and "Page" pages, if set on options page)
            if ( is_single() OR ( is_page() && $bfa_ata_comments_on_pages == "Yes") ) {
                if (function_exists('paged_comments')) {
                    paged_comments_template(); // If plugin "Paged Comments" is activated, for WP 2.6 and older
                    } else {
                    comments_template(); // This will load either legacy comments template (for WP 2.6 and older) or the new standard comments template (for WP 2.7 and newer)
                }
            } ?>
    

    and replace it with something like this:

    <?php // Load Comments template (on single post pages, and "Page" pages, if set on options page)
    if ( is_single() OR ( is_page() && $bfa_ata_comments_on_pages == "Yes" && !is_front_page() )) {
    if (function_exists('paged_comments')) {
    paged_comments_template(); // If plugin "Paged Comments" is activated, for WP 2.6 and older
    } else {
    comments_template(); // This will load either legacy comments template (for WP 2.6 and older) or the new standard comments template (for WP 2.7 and newer)
    }
    } ?>
    

    If your single loop is different from your homepage loop, then you should copy the code that post the comment form from the single loop into the index loop.

  2. Comments can be enabled on pages and / or posts.

    If your wordpress front page displays a static page you can enable comments on it.

    If it happens to display “Your latest posts,” it’s simply a list of some recent posts (formatted according to your theme). There’s no single item, post or page, there to accept comments.

    You can find out how this is set up for your WordPress installation by looking at Settings / Reading on your dashboard.