• I have solved this problem but in a very clumsy way and I was wondering if there was a more elegant solution.

    The problem I would like to display the latest ten posts on my homepage with any associated comments fully displayed under each post. I do not however want ten comment forms on my homepage. I would like the comment form to only be visable when the user views a post as a single post. My site is http://www.langhofc.com if that makes it clearer.

    The (clumsy) solution Searching through the forums I have found the following method to display comments on the homepage.

    1.Open /wp-includes/comment-template.php
    2.Find the “function comments_template( $file = ‘/comments.php’ ){“
    3.Inside the function you will see :
    if ( ! (is_single() || is_page() || $withcomments) )
    return;
    Change this to
    if ( ! (is_single() || is_page() || $withcomments) )
    //return;
    4.Open /wp-content/themes/yourtheme/index.php
    add “<?php comments_template(); ?>” inside post loop
    “while (have_posts()) : the_post(); “

    This displays comments under each post on the homepage but also shows the comment form 10 times, once with each post.
    My workaround has been to add an extra function to the comment_template.php file called partcomments_template which instead of linking to comments.php, links to partcomments.php. The file partcomments.php is identical to comments.php but without the form section.

    Instead of all this would it be possible to put a conditional in the comments.php file which only displays the form part of it if the user is viewing a single post?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter thingymajig

    (@thingymajig)

    sorry to bump but … any ideas anyone?

    Thread Starter thingymajig

    (@thingymajig)

    I’ve now solved this as follows;

    Get comments and comments form to display afetr each post on home page as above.

    Then edit the comments.php file in your theme as below;

    THE CODE TO DISPLAY COMMENTS HERE

    ‘<?php if (is_single()) : ?>’

    THE CODE TO DISPLAY THE COMMENT FORM HERE

    ‘<?php else : // not a single page ?>
    <?php endif; ?>

    <?php endif; // if you delete this the sky will fall on your head ?>’

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display comments but not comments form on homepage’ is closed to new replies.