mintymike
Member
Posted 9 months ago #
hi guys
gotta problem. I'm trying to cancel <ul> from listing category names. right now there's this line in my template:
<?php wp_list_cats('sort_column=name&optioncount=1'); ?>
this one lists categories in a vertical list. I want the names to be shown in a horizontal line, seperated by spaces or slashes.
I read the Codex, found the_category(' '), which should solve my problem (and show the categories just as I want them), but somehow it shows only one category name... And it's always the last category.
Any ideas?
This will use get_categories
<?php
$cats=get_categories ();
foreach ( (array) $cats as $cat ) {
echo 'id = ' . $cat->cat_ID . ' name =' . $cat->name . ' count = ' .$cat->count ;
}
?>
Quoting Codex regarding the_category -- "Displays a link to the category or categories a post belongs to. This tag must be used within The Loop."
mintymike
Member
Posted 9 months ago #
Just one last thing - how can I make an actual link to each category? Because using the code given above the categories are just text. I'd like each category name to be linked with a page containing all the posts from that category.
Line 237 in wp-includes/category-template.php has an example of building a link.
Might also consider this plugin:
http://wordpress.org/tags/enhanced-categories
Also note wp_list_cats is replaced by template tag, wp_list_categories().