• Resolved gamemakker

    (@gamemakker)


    Forgive me being a noob but I am sort of new to using php. I have read that I need to change the $withcomments variable to 1 so that I can have comments on my index page but I don’t realy know how to achieve this.

    Help is greatly appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • I don’t think you can have comments on your index page, It’s not really a page. It’s more of a container for actual pages.

    I could be wrong, but that’s what I think.

    Thread Starter gamemakker

    (@gamemakker)

    Would it be possible to make another page that loads the comments for the latest entry and then include that on the index?

    It’s just an idea but thanks for the help

    @gamemakker

    I’m pretty sure GreenLantern isn’t quite right. In fact, you may want to search the forums here a bit. While I don’t have the answer, I seem to recall this topic being discussed just within the last week or so.

    Thread Starter gamemakker

    (@gamemakker)

    Thankyou I might just keep it simple and avoid anymore hassel

    I use custom comment.php files, so I’m not sure what variables your theme will use, but I just add

    <?php
      $post_id = $post->ID;
      $comments = get_approved_comments($post_id);
    ?>

    to the beginning of my comments.php file. You should at least check out the function I mentioned: get_approved_comments().

    I think wordpress runs a query that performs that function before single.php is called, so calling this function directly does the same thing. That’s just speculation, though. Either way, it works for me.

    Just put

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

    wherever you want the comments to show.

    The function comments_template() checks to see if the call is for a single post or page, or, as Tunneleram suggest, $withcomments is true.

    if ( ! (is_single() || is_page() || $withcomments) )
     return;
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘comments on index page’ is closed to new replies.