Wordpress category description. Please, help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • everestcash
    Confirmed User
    • Apr 2002
    • 2194

    #1

    Wordpress category description. Please, help.

    I wanna display descriptions next to each category name on index page, but I'm not familiar with PHP at all

    I edited the code like this:

    <?php wp_list_cats('sort_column=name'); ?> - <?php echo category_description($cat); ?>
    but it doesn't work properly

    Could you please advice?

    p.s. I thought I need something like show_description parameter that exists for <?php get_links(); ?>
    but seems like it doesn't exists for <?php wp_list_cats('); ?>

  • everestcash
    Confirmed User
    • Apr 2002
    • 2194

    #2
    or maybe you can just give me a link to any theme that uses category descriptions
    so I could look for it in the code

    Comment

    • everestcash
      Confirmed User
      • Apr 2002
      • 2194

      #3
      bump for me

      Comment

      • peterp
        Confirmed User
        • Mar 2006
        • 137

        #4
        please try it with these : <?php category_description(category); ?>

        Comment

        • everestcash
          Confirmed User
          • Apr 2002
          • 2194

          #5
          thanks, but i've already tried that ((

          Comment

          • Bods4Mods
            Confirmed User
            • Nov 2005
            • 904

            #6
            bump for getting it solved

            Comment

            • woman
              Confirmed User
              • Feb 2005
              • 100

              #7
              Try this:
              PHP Code:
              <?php
              $exclude = '';
              
              // $orderby - Category table column (record) to sort on; for column
              // options see note #2 above.
              $orderby = 'cat_name';
              
              // $order - The sort order method. Use 'ASC'ending or 'DESC'ending.
              $order = 'ASC';
              
              /* << user-configurable variables << */
              
              if($exclude) { // set up the category exclude list for the query
                  $and = '';
                  $wherecat = 'AND (';
                  $exclude_cat = preg_split('/[\s,]+/', $exclude);
                  foreach ($exclude_cat as $xcat) {
                      $wherecat .= $and . ' cat_ID <> ' . $xcat . ' ';
                      $and = 'AND';
                  }
                  $wherecat .= ')';
              }
              
              global $wpdb; // making sure the WP database object is around
              /* the next line assigns the query results to $categories */
              $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE category_count > 0 $wherecat ORDER BY $orderby $sort"); // $wp_object_cache->cache['category'];
              ?>
              <?php /* >> category list loop >> the important part! */ ?>
              <?php while(list(,$category) = each($categories)) : // start loop ?>
                      <p>
                      <h3 id="cat-<?php echo $category->cat_ID; ?>"><a href="<?php echo get_category_link($category->cat_ID); // returns category url ?>" title="<?php echo $category->cat_name; ?>"><?php echo $category->cat_name; ?></a></h3>
                      <?php echo $category->category_description; ?> (<?php echo $category->category_count; ?> posts)
                      </p>
              <?php endwhile; // end loop ?>
              <?php /* << category list loop << */ ?>
              Greetings, woman
              Sexgirls! makes money with VideoBox

              Comment

              • everestcash
                Confirmed User
                • Apr 2002
                • 2194

                #8
                Thanks A Lot!

                Comment

                • woman
                  Confirmed User
                  • Feb 2005
                  • 100

                  #9
                  Always at your service! (For questions about wordpress )
                  Sexgirls! makes money with VideoBox

                  Comment

                  Working...