Support » Fixing WordPress » WP LIST CATS help please

Viewing 8 replies - 1 through 8 (of 8 total)
  • just use wp_list_cats()

    Nope, that lists the cats in a list < u l >, I want Computers, Blogging, etc, in a < p > tag.


    You’ll need some custom code to get what you’re after:

    global $wpdb;
    $thecats = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE category_count > 0 ORDER BY cat_name ASC");
    $eor = count($thecats) - 1;
    foreach($thecats as $thecat) :
    <a href="<?php echo get_category_link($thecat->cat_ID); ?>" title="<?php echo wp_specialchars($thecat->category_description); ?>"><?php echo $thecat->cat_name; ?></a><?php if($thecats[$eor] != $thecat) echo ', '; ?>
    <?php endforeach; ?>

    This would take the place of <?php wp_list_cats(); ?> in your template.

    Hi Kafkaesqui,

    Many thanks for the code 🙂

    I am not sure if I am doing something wrong though as this just makes myarchive page white with no code on it.


    I tested the code block above, but one can never be %100 sure…

    It’s probably just bad placement of the code. Pop your template’s source up here: (click New Post at the top), and reply back with the link to it.

    Hi Kafkaesqui,

    Here is the link:

    There is not much on this page so I guess it might conflict with smart archives: so that may be where the conflict is.

    If this is too much work I fully understand.

    Many thanks

    This is working for me:

    I guessed at the placement of my code. I assumed you would want the category listing just above the output from Smart Archives.


    Thank you so much, I had been wanting to do this for so long and was sure there was a plugin. There wasn’t, so you are a life saver.

    Thank you

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WP LIST CATS help please’ is closed to new replies.