WordPress.org

Forums

[resolved] Comments work on Pages but not on Posts (22 posts)

  1. tortuga
    Member
    Posted 5 years ago #

    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!

  2. esmi
    Forum Moderator
    Posted 5 years ago #

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

  3. tortuga
    Member
    Posted 5 years ago #

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

    Any other ideas?

  4. esmi
    Forum Moderator
    Posted 5 years ago #

    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.

  5. tortuga
    Member
    Posted 5 years ago #

    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?

  6. tortuga
    Member
    Posted 5 years ago #

    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.

  7. esmi
    Forum Moderator
    Posted 5 years ago #

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

  8. tortuga
    Member
    Posted 5 years ago #

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

  9. esmi
    Forum Moderator
    Posted 5 years ago #

    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?

  10. tortuga
    Member
    Posted 5 years ago #

    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?

  11. esmi
    Forum Moderator
    Posted 5 years ago #

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

  12. tortuga
    Member
    Posted 5 years ago #

    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.

  13. esmi
    Forum Moderator
    Posted 5 years ago #

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

    inside the Loop on index.php.

  14. tortuga
    Member
    Posted 5 years ago #

    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!

  15. BlackPowderSmoke
    Member
    Posted 4 years ago #

    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" ?

  16. BlackPowderSmoke
    Member
    Posted 4 years ago #

    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.

  17. BlackPowderSmoke
    Member
    Posted 4 years ago #

    Deleted duplicate post

  18. Sapphire
    Member
    Posted 4 years ago #

    The loop starts here:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    and ends here:

    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    From: http://codex.wordpress.org/The_Loop (which is a good reference for The Loop)

    Look at your code, and find those lines. There are variations on the first line, but basically ANY line that says "if have posts" is the start of the loop. Your code needs to go after that line and before the ending line.

  19. BlackPowderSmoke
    Member
    Posted 4 years ago #

    The posts above stated index.php, here is my code for index.php....

    <?php
    /**
    * Front to the WordPress application. This file doesn't do anything, but loads
    * wp-blog-header.php which does and tells WordPress to load the theme.
    *
    * @package WordPress
    */

    /**
    * Tells WordPress to load the WordPress theme and output it.
    *
    * @var bool
    */
    define('WP_USE_THEMES', true);

    /** Loads the WordPress Environment and Template */
    require('./wp-blog-header.php');
    ?>

    >

  20. BlackPowderSmoke
    Member
    Posted 4 years ago #

    Have tried different themes with the same problem, I will check out the index.php inside of the current theme folder.

  21. BlackPowderSmoke
    Member
    Posted 4 years ago #

    It worked, thanks a million.

  22. Sapphire
    Member
    Posted 4 years ago #

    You're welcome! :)

Topic Closed

This topic has been closed to new replies.

About this Topic