• cousinagam

    (@cousinagam)


    Prior to 2.1, I set my sidebar to display only categories 2, 3, and 4, each of which has so many children that I don’t want them to show in the sidebar. Instead each of these has its own category page (e.g., category-4.php) that lists all the children as links. (Category 1 was uncategorized, so I excluded it completely.) The old code:

    <?php wp_list_cats('exclude=1&children=0'); ?>

    With 2.1, I find that wp_list_cats is deprecated. I’m trying to get the same effect with wp_list_categories but am coming up short.

    wp_list_categories('title_li=&show_count=0&child_of=0&hierarchical=0&exclude=1');
    displays the children of categories 2, 3, and 4 but not the categories themselves.

    wp_list_categories('title_li=&show_count=0&child_of=0&hierarchical=1&exclude=1');
    displays the parents (2, 3, 4) and the children.

    wp_list_categories('title_li=&show_count=0&child_of=0&exclude=1');
    (which leaves out ‘hierarchical’) also displays both parents and children.

    I’m sure I’m overlooking something obvious, but as you can see it’s not obvious to me.

    This is the site: Cousin Agam Fhèin

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter cousinagam

    (@cousinagam)

    Just an update… poking around the Codex, I get the impression that 2.1x’s changes mean I can’t get wp_list_categories to do what I want (e.g., show only categories 2, 3, and 4 in the sidebar, <i>without</i> showing their children.

    A workaround came to me in the dentist’s office:

    I added hyperlinks in the sidebar for the three category-specific pages. I entered a text label of “Categories” and under it put links to category-2.php, category-3.php, and category-4.php

    Works just fine.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    I posted this in your other thread, but in case you don’t see it:

    wp_list_categories('include=2,3,4');

    Where there is an exclude, there is usually an include as well.

    Thread Starter cousinagam

    (@cousinagam)

    Otto42,

    I used your format (include=2,3=4), but I’m still getting the children (e.g., children of 4) listed in the sidebar.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Control child categories in WP 2.1’ is closed to new replies.