• Hi all, I’ve searched and searched to no avail.

    My comments are running just fine, except on two specific pages…my category pages, and on product pages where I have some custom PHP code to display random posts. I’m at a loss as to why comments aren’t appearing on these pages, and I’m a tad miffed at myself that I can’t figure it out. Comments are turned on (as mentioned, they appear just fine on other pages), and I am using <?php comments_template(); ?>

    Any help would be massively appreciated. I’m sure it’s something dumb that I’ve missed…

    Here’s a link to the category page and the corresponding PHP:
    https://www.tentononline.com/category/all-courses/html-css

    <div id=”category”>
    <h1><?php if (is_category()) { single_cat_title(); } ?> Training Courses</h1>
    <?php echo category_description($category); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class=”product”>“><?php the_post_thumbnail( ‘single-post-thumbnail’ ); ?><?php the_title(); ?></div>
    <?php endwhile; ?>
    <?php comments_template(); ?>
    <?php get_footer(); ?>

    Here’s a link to the product page and the corresponding PHP:
    https://www.tentononline.com/scratch-building-wordpress-themes-with-photoshop

    <div id=”page”>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
    the_content();
    endwhile; else: ?>
    <p>Sorry, no posts matched your criteria.</p>
    <?php endif; ?>

    <div id=”youmightalsolike”>
    <h1>Other courses you might like <span class=”micromicro unbold bodyfont”>(View all courses)</span></h1>
    <?php
    global $post;
    $postid = $post->ID;
    $args = array(
    ‘orderby’ => ‘rand’,
    ‘showposts’=>6,
    ‘post__not_in’=>array($postid),
    ‘cat’=> ’12’
    );
    query_posts($args);
    while (have_posts()) : the_post();
    echo ‘<div class=”product”>’;
    echo ‘‘.get_the_post_thumbnail().the_title(”,”,false).’‘;
    echo ‘</div>’;
    endwhile;
    ?>
    <?php comments_template(); ?>
    </div>
    <?php get_footer(); ?>

Viewing 1 replies (of 1 total)
  • by default, comments only appear on singular pages, i.e. single posts or static pages.

    you can overwrite this with:

    <?php global $withcomments; $withcomments = 1; comments_template(); ?>

    not recommended bacause many features of the comments functions will not work properly in this setup.

Viewing 1 replies (of 1 total)
  • The topic ‘Comments not appearing below random post php’ is closed to new replies.