Support » Fixing WordPress » parent ,child category help

  • Hii

    i want to display only parent category when some one enter in the any parent category then it should show child category of the that parent category if present . do any trik is there

    i just stuck here

    <?php wp_list_cats(‘sort_column=name&child_of=id’); ?>

Viewing 10 replies - 1 through 10 (of 10 total)
  • solution can be found at:
    or simply add &children=o into the php

    <?php wp_list_cats(‘sort_column=name&children=o’); ?>

    do you mena some thing like this above code is right ?

    That code will show only the parent categories.
    It doesn’t solve the second part – showing chidren on parent pages.

    P.S. But you can always do a search for what you are looking for…

    thank you moshu

    from the search i got below code work for me fine but in the home page it don’t show any categoty but when i reach any top level category it show child category any solution

    <?php wp_list_cats(‘sort_column=id&optioncount=0&
    use_desc_for_title=0&child_of=’ . get_query_var(‘cat’)); ?>

    Probably you have to use some conditional tag(s) – if on the home page show this… if else, show something else.

    sorry to irretate you people again

    i applied below code i get unexpected T_ELSEIF

    use_desc_for_title=0&child_of=’ . get_query_var(‘cat’));
    echo “”;
    elseif (wp_list_category()) ?>

    I am not a coder but that will not work, of course.
    Read again and again the conditionals, especially the Working examples and the Variable sidebar content.

    same here moshu even i am not coder so i am not able to fil this section hope some one solve this issue

    I am not sure it will work, I am just copying from the Codex:

    // let's generate info appropriate to the page being displayed
    if (is_home()) {
    // we're on the home page, so let's show a list of all top-level categories
    echo "<ul>"; wp_list_cats('optionall=0&sort_column=name&list=1&children=0');
    echo "</ul>";
    } elseif (is_category()) {
    // we're looking at a single category view, so let's show _children categories
    echo "<ul>";
    use_desc_for_title=0&child_of=' . get_query_var('cat'));
    echo "</ul>";

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘parent ,child category help’ is closed to new replies.