I'm using Drupal 7 and Views 7.x-3.8. I have a taxonomy term "A" which is related with another taxonomy term "B". I want to retrieve a list of "A", but filtered by those "B" that are present in the URL as query parameters. There can be more than one "B" in the URL.

So I've created a contextual filter with PHP code that finds all "B" IDs in the URL and ends up with something like: "return $B1+$B2+$B3...;". Of course, I've checked the Allow multiple values option.

If I pass only one value (e.g. return "15";), the query runs OK and it brings me all "A" related with the B with ID 15, but if I pass two or more values (e.g. return "15+20";), I get a No query was run message, and nothing in the view.

Is this bug for the Views module? I've also tried to replace the PHP code with a simple return "15+20"; in order to simplify the test case, but I get the same error.

2 Answers 2


I don't know if this would answer your questions, but I just noticed that, not only you need to check "Allow multiple values", you also need to specify "Term IDs separated by , or +" in the "Filter value type" select list.

(using Views 7.x-3.14 at the moment)


This has been here for quite a while but since it is unanswered here is what I've done for similar cases.

First of all, let it be clear that you cannot return more than one value with PHP contextual filter in views. I haven't seen any module or method that allows this. If anyone has please provide it!

You can however supply the values you get with that PHP code to a views block setup with contextual filter. This way you can use those values as a contextual filter considering that your drupal installation has the PHP filter module enabled.

With that and having your contextual filter setup allowing multiple values you would be good to go. If you use validation criteria remember to setup filter value type properly.

The values must be included as a string in the form of "a,b,c,d" for AND or "a+b+c+d" for OR where a, b, c and d are values obtained through that PHP code.

So lets say you have declared $values to contain your values. You would call your views block within a page or block and, using PHP filter to write your output, input the following:

<?php $values = ''; ?>
<?php /** code to get your values in the form of 'a,b,c,d' or 'a+b+c+d' **/ ?>
<?php print views_embed_view('my_view_machine_name', 'my_block_machine_name', $values); ?>

I've successfully used this with over 800 ID's in the string. If by any chance you get errors it could be your server's setup as it currently happens on my dev machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.