WordPress.org

Support

Support » How-To and Troubleshooting » show child category of parent (conflict)

show child category of parent (conflict)

  • fernon
    Member

    @angelsih

    I searched all over the internet but my problem is a bit complicated. I wanted to show the children of my category parent in the submenu. (The code works perfect!).

    But the problem is that the normal pages without children, shows up all the categories in the submenu. It shouldn’t show anything.(Since the page doesn’t have a child)

    Hope you guys can help me out with this! I appreciate it!

    I hope my explanation is clear enough.

    The code I used to display the children of the categories is:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser. ]

    <?php
    if (is_category()) {
    $this_category = get_category($cat);
    }
    ?>
    <?php
    if($this_category->category_parent)
    $this_category = wp_list_categories('orderby=id&show_count=0
    &title_li=&use_desc_for_title=1&child_of='.$this_category->category_parent.
    "&echo=0"); else
    $this_category = wp_list_categories('orderby=id&depth=1&show_count=0
    &title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID.
    "&echo=0");
    if ($this_category) { ?>

    Like to hear from you soon

    Kind Regards,

    Angel

  • The topic ‘show child category of parent (conflict)’ is closed to new replies.