Categories list PHP help
My PHP skills are (still) not what I like them to be, so I was wondering if somebody could help me out here.
In the end I need this:
<ul id="filters"> <li><a href="#" data-filter=".[category-name-here]">green</a>[category-name-here]</li> </ul>
I want to accomplish this with listing the categories from WordPress.
So i.e. I got Categories: Blue, Green and Lovely Pinkish in WP backend, the source will show:
<ul id="filters> <li><a href="#" data-filter=".blue">Blue</a></li> <li><a href="#" data-filter=".green">Green</a></li> <li><a href="#" data-filter=".lovely-pinkish">Lovely Pinkish</a></li> </ul>
Blue, green and lovely-pinkish being WP categories.
What I got up with is this:
<a href="#" data-filter=".<?php $category = get_the_category(); echo $category->cat_name; ?>"><?php wp_list_categories(); ?></a>
Not working so much I’m afraid.
Help is much appreciated.
Thanks in advance, with kind regards,
- The topic ‘Categories list PHP help’ is closed to new replies.