Support » Fixing WordPress » Comments work on Pages but not on Posts

  • Resolved tortuga

    (@tortuga)


    Comment do not appear on my Posts even though I have “Allow Comments” checked in the Dashboard. Comments DO appear on my Pages (see the About page). I cannot figure out what is different between the code or settings for the Page and Post comments.

    I did alter the theme so I may have inadvertently deleted something in the HTML/PHP files but I cannot see what it is. I have tried applying other themes but the behavior is the same no matter what.

    Here is the website: http://rhiannonpaine.com

    I have WP v. 2.8.6 installed.

    There are two sub-blogs on the site (Crooks and Mini) that have the same problem… I copied the files from the main (News) blog which would also support the assumption that something is wrong with the HTML/PHP. Can anyone who is more PHP savvy see what the problem is?

    Thanks!

Viewing 15 replies - 1 through 15 (of 21 total)
  • esmi

    (@esmi)

    Forum Moderator

    Try editing the single.php template file and ensure that it contains <?php comments_template();?> near the end of the Loop.

    tortuga

    (@tortuga)

    Thanks esmi. The single.php template does already include <?php comments_template();?> about 3 lines above endwhile.

    Any other ideas?

    esmi

    (@esmi)

    Forum Moderator

    Perhaps the issue is higher up within single.php. Drop a copy of the file into the WordPress pastebin and post the pastebin url here. Perhaps someone will be able to spot the problem and suggest a solution.

    tortuga

    (@tortuga)

    Thanks esmi. Here is a link to the content of the single.php file:

    I’m thinking, however, that the problem isn’t going to be in this file because I had never touched it until today. When I started editing the theme for my site back in January the Comments did work. The files I have edited are the index, header, footer, page, sidebar, and style but that’s it. Does that give any hints?

    tortuga

    (@tortuga)

    Oops! My bad. I accidentally pasted the single.php code from the default theme in the prior posting. Here is the correct single.php file.

    esmi

    (@esmi)

    Forum Moderator

    Can you drop a copy of comments.php into the pastebin?

    tortuga

    (@tortuga)

    I’ve put the comments.php file into the pastebin. Thanks for taking a look.

    esmi

    (@esmi)

    Forum Moderator

    That file looks fine too. Have you tried:

    – deactivating all plugins to see if this resolves the problem? If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    – switching to the default theme to confirm that this is indeed a theme-specific problem?

    tortuga

    (@tortuga)

    Thanks esmi for sticking with me on this. I had tested the plugin and theme change and that made no difference which is why I initially assumed I must have accidentally damaged the code while I was customizing.

    After much examination I copied a line of code from right under the post title where a digit shows how many comments there are. I had not realized it was clickable because it was so small. So I embellished the copied version with text so that it’s large enough to click and pasted that below the content in the loop. That link goes to the single page where the comments do show. Previously I didn’t even know what the single page looked like because I could never get there.

    Is it possible to make the single page be the default view rather than the multiple-post view?

    esmi

    (@esmi)

    Forum Moderator

    No but you can “fake it” by setting your “posts per page” in Settings/Reading to 1.

    tortuga

    (@tortuga)

    I switched the posts per page to 1 and that definitely helps. Still I would prefer that the comment fields show up on the default page instead of readers having to click the Comment link to go to the Single page. Can I make the Comment Form exist inside the Loop on the index template without causing havoc? If so, what line(s) of code would I add/change and where?

    Thanks again esmi for all your help! I really appreciate it.

    esmi

    (@esmi)

    Forum Moderator

    Try adding:
    <?php $withcomments=1; comments_template(); ?>

    inside the Loop on index.php.

    tortuga

    (@tortuga)

    EUREKA! This is the result I wanted. Thank you, thank you, esmi! You’ve made my day! I really appreciate your sticking with me through the whole thing.

    whew!

    I am having the same problem. Have tried everything.

    Try adding:
    <?php $withcomments=1; comments_template(); ?>

    inside the Loop on index.php.

    When trying the above, I got a template sparse error message. What is meant by “inside the loop” ?

    For clarification: Pre existing comments are displayed, but the post page shows Comments closed.
    I have tried the global settings. Allow Comments option is not given during post editing or new posts.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Comments work on Pages but not on Posts’ is closed to new replies.