WordPress.org

Forums

Comments on category post...they don't show up (2 posts)

  1. Yasp0
    Member
    Posted 1 year ago #

    I use some different category pages, in this case category-1.php where I want to retrieve 1 post from this certain category. This all works fine. Also the comment form appears. But there are a couple of comments on this post...and they don“t show up. When I go the the specific single post I do see the comments...

    I use the following code:

    <?php
     global $cat;
     $recentPosts = new WP_Query();
     $recentPosts->query('showposts=1&cat=1');
    ?>
    <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
    <div class="day"><?php the_time('d') ?></div>
    <div class="month-agenda"><?php the_time('M') ?></div>
    <h1><?php the_title(); ?></h1>
    <p><?php the_content(); ?></p>
    <?php include ('comments.php'); ?>
    <?php endwhile; ?>

    I also tried the normal loop:

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <div class="day"><?php the_time('d') ?></div>
    <div class="month-agenda"><?php the_time('M') ?></div>
    <h1><?php the_title(); ?></h1>
    <p><?php the_content(); ?></p>
    <?php include ('comments.php'); ?>
    <?php endwhile; ?>

    But then also only the comment form appears....and not the comments themselves.

    How to list the most recent post from a certain category and get the comment form and the comments?

    Also used <?php comments_template( '', true ); ?> but no succes...

  2. Yasp0
    Member
    Posted 1 year ago #

    Ok just found out that it does work on a custom page.php file. But then another problem rises. The current menu is not working anymore...and that's quite necessary.

Topic Closed

This topic has been closed to new replies.

About this Topic