8

I've my view filtered by taxonomy term ID.

http://aelasoca.cat/web/

(in the main menu I've links to taxonomy ID's 3 to 8). How can I filter with the taxonomy term alias instead of it's ID ??

(not sure if it's the same issue as in: Views, Taxonomy, Block and Context... What am I doing wrong? )

1 Answer 1

24
  1. Create a new Taxonomy:Term ID contextual filter.
  2. Under the form "When the filter value IS in the URL..." select the option "Specify validation criteria".
  3. Select "Taxonomy Term" as the validator.
  4. Select which of your vocabularies you'd like to use.
  5. Under "Filter Value Type" select "Term name converted to term ID".

That should do it. If you have multiple-word taxonomy terms, you should allow the contextual filter to convert dashes in the URL into spaces for the term name. If you have unusual characters in your taxonomy terms, see this post for tips.

6
  • 3
    user812794, you are my hero! This solution on translating term ID to term name just saved me from severe brain damage. Thanks!
    – user2386
    Aug 8, 2011 at 7:39
  • FWIW, this also enables making a view a feature, so you can not count on term ID and name match across different sites.
    – Screenack
    Feb 10, 2016 at 17:38
  • How do you compose the URL in cases like this?
    – Hawkee
    Mar 28, 2016 at 10:11
  • 1
    @Hawkee the URL should be defined in your View as something like /your-url/%, where % represents the term name that the contextual filter uses to filter the view. So once you've defined that in the View, you could go to /your-url/gouda and see articles dealing with gouda (for a cheesy example).
    – areynolds
    Mar 29, 2016 at 16:31
  • Must be the solution for Views 2.x because the option on line 2 is not available in Views 3.x.
    – Patrick
    Oct 24, 2016 at 16:39

Your Answer

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

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