Support » Plugins » Showing comments on homepage with $withcomments – not working for me

  • Resolved cosmocanuck

    (@cosmocanuck)


    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • cosmocanuck

    (@cosmocanuck)

    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?

    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();
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Showing comments on homepage with $withcomments – not working for me’ is closed to new replies.