Forums

Showing Category Descriptions in category list (6 posts)

  1. webstergroup
    Member
    Posted 3 years ago #

    Does anyone know how to get wp_list_categories to show the descriptions as well as the names of the categories?

  2. stvwlf
    Member
    Posted 3 years ago #

    As far as I know its not straightforward.

    Instead of echoing the output from wp_list_categories to the browser, as normally done, you load it into an array and then process the array with a foreach loop. In that loop you look up the cat descrip for that cat and format how you want all the cat fields displayed.

  3. webstergroup
    Member
    Posted 3 years ago #

    *SIGH* I was starting to get that impression by reverse engineering the "Category Icons" plug-in. Can you point me somewhere where I can read about using the array?

  4. stvwlf
    Member
    Posted 3 years ago #

    The codex page
    http://codex.wordpress.org/Template_Tags/wp_list_categories

    in wp_list_pages, include (echo=0) parameter

    something like

    $cats = wp_list_pages(echo=0&...other params...);
    foreach ($cats as $cat):
    ... code here to process cats ...
    endforeach;

    you can do a print_r($cat) to see the fields in the $cat array

    also see this
    http://codex.wordpress.org/Template_Tags/category_description

  5. Copernicus
    Member
    Posted 3 years ago #

    I believe this thread will give you the proper code for displaying a category list along with each category's description:
    http://wordpress.org/support/topic/151935?replies=4#post-832204

  6. submarine
    Member
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic