Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Sub Category Description in a query WordPress

  • SOLVED

Hello everyone :)
I found this loop on the [[LINK href="http://wordpress.org/support/topic/show-sub-categories-when-on-parent-category-page?replies=9"]]wordpress forum[[/LINK]] and try to integrate it with the '[[LINK href="http://wordpress.org/extend/plugins/category-icons/"]]category icons[[/LINK]]' plugin.
I have a question though, anyone knows how to include the sub-category description?
Here's what I have so far:
<ul class="featprod-item">
<?php if( is_category() ) {
$cat_id = get_query_var('cat');
$cat_ancestors = array();
$cat_ancestors[] = $cat_id;
do {
$cat_id = get_category($cat_id);
$cat_id = $cat_id->parent;
$cat_ancestors[] = $cat_id; }
while ($cat_id);
$cat_ancestors = array_reverse( $cat_ancestors );
$top_cat = $cat_ancestors[1];
if (function_exists('put_cat_icons')) put_cat_icons( wp_list_categories('use_desc_for_title=1&orderby=name&title_li=&child_of=' . $top_cat.'&echo=0'));
else wp_list_categories('use_desc_for_title=1&orderby=name&echo category_description()&title_li=&child_of=' . $top_cat);
}
?>
</ul>

Thanks!

Answers (1)

2011-02-04

Rashad Aliyev answers:

Please give me your site URL.


Rashad Aliyev comments:

Use this code for your theme.

echo '<ul class="featprod-item">';
foreach(get_categories("orderby=name&order=ASC") as $category) {
// Get the icon in a variable
$my_icon = get_cat_icon('echo=false&cat='.$category->cat_ID);
// Display a list with icons and the category names
echo '<li>'.$my_icon.' '.$category->cat_name.'<font color="#ccc">'.$category->description.'</font></li>';
}
echo '</ul>';




best regards,