HI Sylvia,
This is what worked for me. It is basically what MichaelH provided me with in this thread (Thanks Again!)
I put this code into my sidebar, then defined the classes catTitle and catDesc in the style sheet (style.css in most themes).
I used it in my friends blog here:
https://www.westcoastcoaching.com
She uses her categories more like headings with her last three posts showing. You can change that number in this line
‘showposts’ => 3,
This code also will reveal the description of the category as it is written in the admin (dashboard) under categories. In the example site above there is nothing written in the category description, but is there if you need it.
———————————– JPF
<?php
$cat_args=array(
‘orderby’ => ‘name’,
‘order’ => ‘ASC’
);
$categories=get_categories($cat_args);
foreach($categories as $category) {
$args=array(
‘showposts’ => 3,
‘category__in’ => array($category->term_id),
‘caller_get_posts’=>1
);
$posts=get_posts($args);
if ($posts) {
echo ‘<p>term_id.'” class=”catTitle”>’. substr($category->name,0,30) .’</p> ‘;
echo ‘<div class=”catDesc”>’. substr($category->description,0,100) .'</div> ‘;
foreach($posts as $post) {
setup_postdata($post);
echo ‘<p>ID.'” class=”catPosts”>’ . substr($post->post_title,0,45) . ‘</p> ‘;
} // foreach($posts
} // if ($posts
} // foreach($categories
?>