WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Showing comments on homepage with $withcomments - not working for me (3 posts)

  1. cosmocanuck
    Member
    Posted 4 years ago #

    Hi! After much searching and teeth-gnashing, I thought I'd found the solution to my issue of not being able to make the comments box appear on the homepage.

    The solution appears to be to add this code:

    <?php $withcomments = true; comments_template();?>

    Instead of just

    <?php comments_template(); ?>

    ...to home.php .

    This supposedly gets around a built-in block on showing comments on the homepage which is written into wp-includes/comment-template.php.

    However, when I add this to the theme I'm working with, it only works for the first post on my homepage, then on the second I get an error:

    Fatal error: Cannot redeclare k2_comment_type_detection() (previously declared in /home/brainedx/public_html/wordpress/wp-content/themes/cutline/comments.php:15) in /home/brainedx/public_html/wordpress/wp-content/themes/cutline/comments.php on line 15

    And the rest of the page including the sidebar fails to load.

    Kind of stymied on this one.

    Can it be so difficult to have the comments entry field show on the homepage? He asked rhetorically...

    Any help much appreciated. Thanks!

    Adam

  2. cosmocanuck
    Member
    Posted 4 years ago #

    AHA! It was the code for the "k2_comment_type_detection" function in comments.php that caused this problem. Though I don't know why. Seems to be something about detecting comments vs. pingbacks.

    I deleted references to this function in comments.php and all is good.

    Will I miss this code?

  3. Leve
    Member
    Posted 3 years ago #

    Hello !
    I am using this code to show comments on my indexpage but this code outputs all the comments, i would love if the code could fetch the 3 latest comments in a post, is this possible?

    <?php
    global $withcomments;
    $withcomments = true;
    comments_template();
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic