Viewing 8 replies - 1 through 8 (of 8 total)
  • lobsterman

    (@lobsterman)

    just use wp_list_cats()

    Thread Starter elyonline

    (@elyonline)

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

    Thanks

    Kafkaesqui

    (@kafkaesqui)

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

    <?php
    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.

    Thread Starter elyonline

    (@elyonline)

    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.

    Thanks
    Karl

    Kafkaesqui

    (@kafkaesqui)

    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: http://pastebin.co.uk/ (click New Post at the top), and reply back with the link to it.

    Thread Starter elyonline

    (@elyonline)

    Hi Kafkaesqui,

    Here is the link: http://pastebin.co.uk/603

    There is not much on this page so I guess it might conflict with smart archives: http://justinblanton.com/projects/smartarchives/ so that may be where the conflict is.

    If this is too much work I fully understand.

    Many thanks
    Karl

    Kafkaesqui

    (@kafkaesqui)

    This is working for me:

    http://pastebin.co.uk/605

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

    Thread Starter elyonline

    (@elyonline)

    Kafkaesqui,

    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
    Karl

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