• 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

    (@kortschot)

    Im still looking in to this, so when somebody has something to add, please don’t hesitate to do so.

    Thread Starter kortschot

    (@kortschot)

    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.