Passing value to wp_list_categories
-
I can’t seem to get it to work. I am trying to make a nav that goes through my subcategories, only listing the child categories of the current category.
-
<?php
$cat = get_query_var(‘cat’);
$num = (int)$cat;
echo $num;
wp_list_categories(‘orderby=id&show_count=1
&use_desc_for_title=0&hide_empty=0&child_of=$num’); ?>I am trying to pass the current category to the child_of parameter and it does not accept it. I echoed the $num and that is fine. The docs say child_of should be an integer. It works fine when I plain out write the number like child_of=10, but not when I use a variable. Perhaps it only accepts constants? Or am I doing something wrong. I am new to php so any help would be appreciated.
- The topic ‘Passing value to wp_list_categories’ is closed to new replies.