• Hi guys,

    Please help me! I’m trying to list the children of a specific category which I’ve selected. I’ve tried the coding below but I encouter the error “Parse error: parse error, unexpected T_STRING in”.

    The code i use is:

    wp_list_cats(‘sort_column=id&optioncount=0&use_desc_for_title=0&child_of= ((int) echo get_query_var( ‘cat’ )) ‘);

    Basically I’m trying to dynamically pass the category ID when i select the category.

    I managed to get the echo get_query_var( ‘cat’ ) to display the ID but just that the parsing seems wrong.. please help me!

    Thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try this:

    wp_list_cats('sort_column=id&optioncount=0&
    use_desc_for_title=0&child_of=' . get_query_var('cat'));

    Couple follow up points to Aleister’s solution: echo is a print command; never incorporate it in a function’s argument list. To pass a value from another function as an argument, you need to keep it out of quotes–and notice the use of the dot (.) operator to concatenate the argument string with the value from get_query_var().

    Nicely put ??

    Thread Starter mendna

    (@mendna)

    thank you guys so much!

    It works like a charm and I’ve learnt something again today!

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Listing out children of a specific category’ is closed to new replies.