Adding 'category icons' using widgets in wordpress?

Discussion in 'HTML & Website Design' started by js09, May 10, 2007.

  1. #1
    On my sidebar I have different categories that are all the same style. the CSS code is:
    li.widget h2, li.linkcat h2 (line 297)
    {
    width: 190px;
    font-weight: bold;
    font-size: 1.077em;
    text-transform: uppercase;
    letter-spacing: normal;
    margin-top: 0pt;
    margin-right: 0pt;
    margin-bottom: 0.8em;
    margin-left: 6px;
    padding-top: 0.4em;
    padding-right: 2px;
    padding-bottom: 0.4em;
    padding-left: 0pt;
    border-top-width: 3px;
    border-top-style: solid;
    border-top-color: #cfcfcf;
    background-image: url(http://www.niftytutorials.com/wp-content/themes/nifty-v1/images/hr_line_black.gif);
    background-repeat: no-repeat;
    background-x-position: 0pt;
    background-y-position: 100%;
    }
    Code (markup):
    so i'm unsure how to give EACH category its own image. For example, if i change the background image it is changed for every category.

    Any ideas how I can customly give each categories there own classes or something of the like? thanks.
     
    js09, May 10, 2007 IP
  2. parag

    parag Banned

    Messages:
    62
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You cant directly do it in wordpress.
    You will have to write a custom MYSQL query for it.

    Get all the categories into an Array and then return them from the function.
    Then use different classes for each array element or as you may like.

    Here's what wordpress uses on line 87 in category.php to get the categories from the database.
    $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where ORDER BY $orderby $order $number");
    Code (markup):
    Use something like this to have all the categories in the $something Array and do as I have said above.

    - Parag
     
    parag, May 10, 2007 IP
  3. js09

    js09 Peon

    Messages:
    232
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    oof, thats a bit above my level. I understand what you are saying but i lack knowledge right now. thanks though.
     
    js09, May 10, 2007 IP