I have the following code implemented on my site to grab the mos recent posts from all categories and then list the other most recent posts from the categories underneath by just their titles, but I am trying to find a way to have it do this for only ONE category for that section and not for all the categories. Any suggestions?

<ul id="cat-listing">

<? $categories = get_categories();foreach ($categories as $cat) { ?>
<li class="cat-block">
<h3><?echo $cat->name; ?></h3>
<?php $catID = $cat->cat_ID;
query_posts("showposts=8&cat=$catID");
$first=1;
$ul=0;
while (have_posts()) : the_post();
// Latest post with excerpt
if($first) {
?>
<div class="cat-most-recent">
<h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
<div class="cat-list-excerpt">
<?php the_excerpt(); ?>
</div>
</div>
<?php
$first=0;
} // end if
else { if ($ul==0) {
echo '<ul class="cat-recent-list">';
$ul=1;
}
?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php } // end else ?>
<?php endwhile; ?>
<?if ($ul) echo '</ul>' ?>
</li>
<?php } //end foreach ?>
</ul>

    so for arguments sake lets take this tree

    finance
    --stocks
    --porfolio

    news
    --sports
    --headlines
    --health

    so what you are saying is that your site would take that tree, grab all the posts from each main category, then for each sub category, grab just the post titles

    and what you are trying todo is say for JUST finance get all these sub category post titles and for the rest just get the posts for each main category?

      I don't have any sub-categories set up, everything is working in just main categories. What i'm trying to do is have the most recent post from a category display with the excerpt from the post showing, while the previous posts under that same category are only shown as titles.

      Right now it's grabbing the posts from every category on my site instead of just grabbing from a single category,such as Finance. So instead of taking just one tree, it's grabbing the entire forest.

        I'm very new to PHP and wordpress and am just trying to find a solution/adujustment to my current code to get it to show only one category.

        Do you know what I have to fix or adjust int he code to get it to do so?

          if you want to tell me EXACTLY what category and section you want to pull data from I can code something simple together for you to meet your needs 🙂

            the category is called "national", the posts i want to show up are in that category, dont have any sections inside of it or inside any other categories that I need to show up.

            Thanks!

              can you post a link to that page? i dont see national as a main category on the msnbc homepage

                Write a Reply...