Contextual Filters with PHP code I am setting up a contextual filter for several taxonomy fields on a content type that stores my organizations records.  I want to present my users with a nice looking url, not the TID.  For the contextual filter, I have selected Provide a Default Value and selected Use PHP Code. This is the code:

$term_name = "Open";
$termObj = taxonomy_get_term_by_name($term_name);
$term = reset($termObj);
return $term-&gt;tid;


For now, I'm hard coding the term until I can get it working, then I'll switch it to a term out of the URL. When I save the contextual filter, the preview shows "No query was run". After I save the view and visit the page created by the view, Drupal gives me a Page Not Found message.
As I am always against adding PHP code in the UI may I suggest a different approach?

Add a relationship to your view "Content: age group", which is the relationship from your term reference field to the taxonomy term.

Then add a contextual filter "Taxonomy term: Name", using the relationship you just added.

Then the argument will be the term name without you having to add custom PHP code.