Categories and Descriptions
-
I want to display a list of categories along with their descriptions on the main page. I have looked and I have looked and all I can find are loops to display categories only or descriptions for single categories only.
What I need is a loop that displays category – Description . I have managed to do this using the following code. However, I need to cut out the categories without posts in them. How do I do that? Or is there a plugin that I can use but haven’t found yet ??
<?php
$categories = $wpdb->get_results(“SELECT cat_ID, cat_name, category_nicename, category_description, category_parent FROM $wpdb->categories
WHERE cat_ID > 0 $exclusions
ORDER BY cat_name”); ?><?
foreach($categories as $np){
print (“<h2><a href=\””);
echo get_category_link($np->cat_ID);
print (“\”>$np->cat_name</h2><p style=\”font-size: 90%; padding-top:0px; margin-top:0px;\”>
$np->category_description”);
}?>
———————-
Q2 From what I can see using the tag: <?php the_category(‘, ‘) ?> is supposed to seperate the categories with a ‘,’ which I take to mean that it should display as: Parent Category, Sub Category, Sub Sub Category.
But I only get a single category for the Sub Category and Sub Sub Category.
- The topic ‘Categories and Descriptions’ is closed to new replies.