• infovore

    (@infovore)


    OK, I’m stumped. I’m relatively experienced in WP and have a good amount of PHP, but this one’s got me entirely stuck.

    Essentially: I’m trying to list the most recent three posts in a single category on the post page (single.php).

    On the front page, I’ve got multiple loops running all fine, as per Ryan’s suggestions in the codex. My single page also has a loop at the top which (supposedly) pulls the date from the most recent post (yes, not the post on display).

    So, on the single.php page, I’ve got this code:

    <?php
    $thiscatsarray= get_the_category();
    $thiscatname= trim($thiscatsarray[0]->cat_name);
    query_posts('category_name=$thiscatname&showposts=3');
    while (have_posts()) : the_post(); ?>
    <li><i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></i></li>
    <?php endwhile; ?>

    Kludgey, I know. I’m stumped as to why it doesn’t work, simply because: I *know* that $thiscatname is correctly displaying the plaintext name of the category, and that while loop that I’m using is *exactly* what I use on my index.php to achieve similar results. So: any suggestions as to why this doesn’t work – and, indeed, any alternative ideas? Much appreciated.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Listing other posts in category on single post page’ is closed to new replies.