Forums

[resolved] Comments on index.php (problem) (6 posts)

  1. Zejho
    Member
    Posted 1 year ago #

    Hey.

    I want to have the comments of each post shown on the index page, so I searched around and found this:
    <?php $withcomments = "1"; $comments_template; ?>

    It's not working as it should, though. I can get the comments to show, but they are all the same no matter which post it is.

    You can see for yourself here. Just click on "Visa kommentarer" beneath the post and they will appear.

    hope you can help :)

  2. stvwlf
    Member
    Posted 1 year ago #

    Look at your theme's single.php template file. Find the code that displays the comments after the post content. Copy it and paste it into the index.php file in the same location, INSIDE THE LOOP. That is, before the closing ENDWHILE.

    Make sure you make a backup copy of your index.php file before you change anything.

  3. Zejho
    Member
    Posted 1 year ago #

    The only code that I can find in the single.php file that has something to do with the comments is <?php comments_template(); ?>. So not much help there, I'm afraid, as I've already included that in my index.php file. And it's inside the loop.

  4. stvwlf
    Member
    Posted 1 year ago #

    That generally is what is needed to display comments. That's all the help I can offer with the information you've provided.

  5. Zejho
    Member
    Posted 1 year ago #

    Anyone else got any ideas? It's driving me crazy :/

  6. Zejho
    Member
    Posted 1 year ago #

    Finally got it working. I just passed two arguments to the comments function, like this: <?php comments_template('/comments.php', true); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic