[resolved] Displaying Only Child Categories of Parent (6 posts)

  1. lowestformofwit
    Posted 8 years ago #


    I'm using WP 2.0.x and I am trying to only display a child category when the user clicks a specific parent category.

    Now the variable which holds the current category is $cat and when I echo it out it works fine. But when I use it in my code it ignores the variable and doesn't display my child categories at all.

    Works: wp_list_cats('sort_column=id&optioncount=0&use_desc_for_title=0&child_of=2');

    Doesn't work:

    Can someone shed some light on this? For something that looks so simple this is driving me insane.



  2. lowestformofwit
    Posted 8 years ago #

    There's got to be theme and plugin developer gurus out there who can help me with this simple question? Surely?

  3. moshu
    Posted 8 years ago #

  4. lowestformofwit
    Posted 8 years ago #

    Thanks but no, that doesn't help me I'm afraid. I've already installed that plug-in. It works but only displays child categories beneath parent categories which looks messy on my blog.

    What I am really trying to do is have one list of parent categories in one column and show specific child categories in another column when a user clicks a specific category.

    Has anyone been able to do this?

  5. Kafkaesqui

    Posted 8 years ago #

    A PHP variable will be read as a literal string ($cat instead of 2) when in single quotes, so switch to double-quotes to surround arguments that include a variable:


  6. lowestformofwit
    Posted 8 years ago #

    Thank you very much.

    Double quotes, that's all I was missing. I knew it would be something easy like that.

    I will mark this as resolved and hope it will help others in a similar situation.


Topic Closed

This topic has been closed to new replies.

About this Topic