mdesilets
Member
Posted 5 years ago #
I would like to be able to list all of the child categories underneath a specific category and display them with a title and description of what that category is. An example of how I would like it to display is here Link (the images are not necessary).
All of the resources I have found so far... list_categories etc. Put the results into a UL or OL... Can someone point me in the direction of a custom category query or other plugin / resource that might be helpful?
mdesilets
Member
Posted 5 years ago #
The code I was trying to work with...
<?php wp_list_categories('orderby=id&show_count=10
&use_desc_for_title=1&child_of=5'); ?> <?php echo category_description(5); ?>
while this does list the categories... and the second part lists the description... they dont work together... I think I should be using a template but dont know where to start
WordPress doesn't have any way to do what you're asking. Look for a plugin to do it or write your own custom code to do it.
mdesilets
Member
Posted 5 years ago #
Otto,
Thanks for your reply! I've almost solved my problem :) now all I need is some styling and a pesky more link... Is there a cleaner way to do this?
<?php
$categories = get_categories("title_li=&orderby=name&hide_empty=0&child_of=5");
foreach ((array) $categories as $cat) {
$cat_link = '<h2 class="subhead1"><a href="' . get_category_link($cat->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $cat->cat_name) . '" ' . $rel . '>' . $cat->cat_name.'</a></h2>';
?>
<p><?php echo $cat_link . '' . $cat->category_description; ?></p>
I would have written it like this:
<?php
$categories = get_categories("title_li=&orderby=name&hide_empty=0&child_of=5");
foreach ((array) $categories as $cat) {
?>
<h2 class="subhead1"><a href="<?php echo get_category_link($cat->cat_ID); ?>" title="View all posts in <?php echo $cat->cat_name; ?>"><?echo $cat->cat_name; ?></a></h2>
<p><?php echo $cat->category_description; ?></p>
<?php } // end foreach loop ?>
mdesilets
Member
Posted 5 years ago #
that does make more sense... thank you again for your time