WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to show a list of only one category (3 posts)

  1. kud0gfx
    Member
    Posted 6 years ago #

    i have categories and sub-categories.... for example

    category 1
    sub-category 1
    sub-category 2
    sub-category 3
    category 2
    sub-category 1b
    sub-category 2b
    sub-category 3b

    when i write the code
    <?php wp_list_cats('sort_column=name'); ?>

    it shows all of my categories like this:
    category 1
    sub-category 1
    sub-category 2
    sub-category 3
    category 2
    sub-category 1b
    sub-category 2b
    sub-category 3b

    but I only want to show the sub-categories of category 1:

    sub-category 1b
    sub-category 2b
    sub-category 3b

    is it possible?

    thank yous o much

  2. Kafkaesqui

    Posted 6 years ago #

    1. If using WP 2.1 or above, I would suggest switching to wp_list_categories():

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

    The template tags list_cats/wp_list_cats have been deprecated.

    2. See the information on the 'child_of' parameter.

    http://codex.wordpress.org/Template_Tags/wp_list_categories#Parameters

  3. kud0gfx
    Member
    Posted 6 years ago #

    thank you so much! it's just what i was searching for!

Topic Closed

This topic has been closed to new replies.

About this Topic