0

So I have this view that searches for content (articles, blogs, etc.) associated with a particular author name. Is there a way with this that I can pass a contextual filter of taxonomy terms that would filter out content?

So let's say we have a couple articles tagged with "love", and "questions" but I have one article also tagged with "talk". Is there a way I can pass that term "talk" as a contextual filter (or filter criteria) to block it from showing up in the list? Essentially I'm hoping there is something like "Content: Does not have taxonomy term ID" or something like that.

enter image description here

1
  • Does adding a relationship to taxonomy provide new filter options? – Kevin May 26 at 15:19
1

Regular Filter

You can add the regular Filter for the Taxonomy term Entity Reference field, select the Is none of under Operator, and then click to select "talk" from the terms list.

Contextual filter

You can also use the Exclude option in the Contextual filter for the ER field. I would use this option only if I needed the filter to be Contextual for some reason, if I needed options that come with it, otherwise just use the regular filter.

  1. Add the Contextual filter for your Taxonomy term Entity Reference field, and configure it with these options:
    When the filter value is NOT available
    Provide default value
    Fixed
    [Taxonomy term ID for "talk"]
    When the filter value IS available or a default is provided
    Specify validation criteria
    Taxonomy term ID
    [Your Vocabulary]
    More
    Exclude

  2. Check your results to see if the content tagged with "talk" is removed.

    Enter all into Views Preview field to bypass the Contextual and check if the "talk" nodes come back (be careful if you have more than one Contextual filter, you may need to provide more than one argument for Views to show results).

8
  • How can I use this to exclude multiple taxonomy terms? I've tried using the term name (as TermName1+TermName2) and even tried the term ID (231+344) and it doesn't return anything. – user1470118 May 27 at 17:00
  • Of course, you can exlude multiple terms from results. In the regular filter just select all the terms you want to exclude (hold Ctrl while clicking to add to the selection). If it's contextual did you enable the option to accept more than one argument? Names won't work directly since ER fields only store IDs (numbers). Once you get it working with IDs you can add a Relationship to filter by name, then configure it almost identically as IDs only validate according to names. – prkos May 27 at 17:11
  • I am using it as contextual filters, and in the views preview I entered it as 19492/11302+114 but didn't get anything back. I tried it as 19492/11302 and got values back. I do have it checked to allow more then 1 argument and when I click to preview it says no query was run. – user1470118 May 27 at 17:31
  • How many Contextuals do you have? Can you update the Q with their config and test results? – prkos May 27 at 17:33
  • I have 2 contextual filters, the author (node ID) and the terms to exclude. – user1470118 May 27 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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