PHP help

Out of context: Reply #5

  • Started
  • Last post
  • 13 Responses
  • MrDaro0

    Not quite yet.
    This is the scenario:

    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.php

    if (in_category (array($usercategories) ) { ...my loop... }
    it does not recognize the variable, I try to manually enter the value just to check and it works.

    if (in_category (array(1,2,3) ) { ...my loop... }

    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?

View thread