Why not use wp_list_categories?
well, i don’t know… can i get the descriptions? and format the text/lnks?
See the right side:
http://springboard.com.s75811.gridserver.com/what-we-do/
This is more or less hard coded right now…
And please forgive any messed up stuff- I had to move the site from Yahoo today…
Does anyone know how to accomplish this?
I had the same problem! I wanted to output my sidebar category links using this method instead of wp_list_categories so I could safely add a custom bullet on each <li>.
To link each one, I used get_category_link with each specific cat_ID and it worked like a charm. Here is my loop:
<li><h4>Categories</h4>
<ul><?php $categories = get_categories();
foreach ($categories as $cat) { ?>
<li class="cat-item">» <a href="<?= get_category_link( $cat->cat_ID ); ?>"><?= $cat->cat_name; ?></a> <?= '('.$cat->category_count.')' ?></li>
<?php } ?>
</ul>
</li>
Cheers!
Thanks Marcy-
I actually found a PHP/Wordpress programmer to help me with this- We took it a step further by adding the description and changed the color of the link when active… Here’s the code we used…
<?php
$categories = get_categories('depth=1&hide_empty=false&exclude=9,18,27');
foreach ($categories as $cat) {
// Gets currently selected category id.
$id = get_the_ID();
$category = get_the_category($id);
if($category[0]->cat_ID == $cat->cat_ID){
if(!is_page()){ $link_color = 'style="color:#007fc2;"'; }
echo '<h2 ><a href="'.get_option('home').get_option('category_base').'/category/'.$cat->category_nicename.'/"' . $link_color . '>'.$cat->cat_name.'</a></h2>';
}
else{
echo '<h2><a href="'.get_option('home').get_option('category_base').'/category/'.$cat->category_nicename.'/">'.$cat->cat_name.'</a></h2>';
}
if ($cat->category_description != '') {
echo '<p>'.$cat->category_description.'</p>';
}
else{
echo '<p> </p>';
}
if ($cat->category_parent != 0) {
echo '<p> </p>';
}
}
?>