User inputted text as variable not working all the time
-
I have a form which asks the user for one or more category ID’s separated by comma. Thus the user will enter 1,2,3 without quotes. The value is stored in a variable called $usercategories
If I use
<?php wp_list_categories('include='.$usercategories.'&title_li=' ); ?>
It works fine, I’ll get a list of only those categories. However when I try to use the variable in my single.phpif (in_category (array($usercategories) ) { ... }
it does not recognize the variable, I try to manually enter the value just to check and it does work.if (in_category (array(1,2,3) ) { ... }
if I echo the variable it outputs the list too eg 1,2,3
I just don’t understand why the variable it’s not working when used as a parameter for a function. Any ideas?
- The topic ‘User inputted text as variable not working all the time’ is closed to new replies.