• Hi all,

    Been struggling with this for a while now. For reasons I won’t go into I want to display the most recent post from one of three categories. Should be simple enough but I just can’t get it to work. The effect, once it works, should be that the posts ‘switch’ depending on which is most recent.

    Additional complication is that each post is displayed using a category template. At present I have the current code, which follows on as second pass through the loop (the previous pass pulls out the most recent post from one particular category):

    ?php $class = [THIS IS THE BIT I CAN’T FIGURE OUT]; ?
    ?php query_posts(‘cat=’ . $class . ‘&showposts=1’); ?

    ?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?

    ?php if ($class==1) {
    include(“news.php”);
    } if ($class==3) {
    include(“shortlist.php”);
    } elseif ($class==4) {
    include(“nomination.php”);
    } ?

    The first line is what’s causing me problems, I’ve tried a query_posts but that doesn’t seem to display anything. It’s definitely running this far through the code (if you chuck in a character after this chunk it gets repeated five times on the page). No matter what I’ve tried I can’t pull any post onto the page. I’m already using coffee2thingies plugin elsewhere and it doesn’t do exactly what I want.

    Suggestions?

  • The topic ‘Display (and style) most recent from certain categories’ is closed to new replies.