Title: Categories list PHP help
Last modified: August 20, 2016

---

# Categories list PHP help

 *  [kortschot](https://wordpress.org/support/users/kortschot/)
 * (@kortschot)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/categories-list-php-help/)
 * Hi there,
 * 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[0]->cat_name; ?>"><?php wp_list_categories(); ?></a>
       ```
   
 * Not working so much I’m afraid.
 * Help is much appreciated.
 * Thanks in advance, with kind regards,
    Paul

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [kortschot](https://wordpress.org/support/users/kortschot/)
 * (@kortschot)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/categories-list-php-help/#post-2671933)
 * Im still looking in to this, so when somebody has something to add, please don’t
   hesitate to do so.
 *  Thread Starter [kortschot](https://wordpress.org/support/users/kortschot/)
 * (@kortschot)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/categories-list-php-help/#post-2671938)
 * this just came to mind….
 *     ```
       <?php
       foreach((get_the_category()) as $category) {
           echo '
       <li><a href="#">cat_name . '">' . $category->cat_name .'</a></li>
       ' ;
         }
       ?>
       ```
   
 * Can’t test it out atm, does this look like a feasible solution?
    Think I’m messing
   up all the points and apostrophes in the PHP.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Categories list PHP help’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [isotope](https://wordpress.org/support/topic-tag/isotope/)
 * [list_categories](https://wordpress.org/support/topic-tag/list_categories/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 2 replies
 * 1 participant
 * Last reply from: [kortschot](https://wordpress.org/support/users/kortschot/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/categories-list-php-help/#post-2671938)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
