Forums

[resolved] How to fetch the comments and show them? (4 posts)

  1. marlun
    Member
    Posted 3 years ago #

    Hello everyone!

    I'm making my first theme for Wordpress and actually also using Wordpress for the first time. I've come as far as to when I want to fetch to comments to a specific post and show them.

    I've looked at the default themes's comments.php and I believe I'm doing what it does to get the comments but for some reason a post that I've got that has 1 comment does not show any comments. I get the "Sorry, no posts matched your criteria." when viewing that post.

    The code I've done to fetch the comments: http://pastebin.com/500510

    This code is inside the loop. I've not created or added anything to the $comments variable but in the "default" theme's comments.php it doesn't seem to be any creation or adding to the $comments variable either, so I thought that wordpress creats the $comments variable internally.

    Can anyone tell me what I'm doing wrong, or what I'm missing?

    Thanks in advance!

  2. marlun
    Member
    Posted 3 years ago #

    Hello again!

    No one who knows what I'm doing wrong? I still havn't fixed this and it seems kinda basic. I thought I would give you some more code because what I'm doing wrong may be somewhere before that other code.

    http://pastebin.com/501334

    There you got some more code, the rewind_posts(); in the top is there because my Sidebar is before this code and it also has a loop.

    Thanks in advance for any comments!

  3. marlun
    Member
    Posted 3 years ago #

    Intead of having the comment part in the single.php I added <?php comments_template(); ?>, and now the comments seem to be shown. However. I still get the "Sorry!, no posts matched your criteria." even though the <?php if (have_posts()) : ?> is true. Thats weird.

    Any ideas?

  4. marlun
    Member
    Posted 3 years ago #

    Nevermind, I used a <? else: ?> which ofcourse should be <?php else: ?>, sorry for that, seems to work now =)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.