How to use URL query parameter on a View Exposed Filter? We have a View which has the following settings. How can we setup the view to use a query parameter from the URL to filter the results?

Article Content Type (fields):


Title
Body
Category (field_category) --> taxonomy
Type (field_type) --> taxonomy


View Exposed Filters (values)


Category (All, Security, IoT, Wifi, Network)
Type (All, Blog, Press Release, Breaking News)


Desired output:


When the URL is www.mysite.com/news?type=Blog, then set filters Type=Blog and Category=All to return results of all Article pages where type=Blog and Category can be any (not null)
When the URL is www.mysite.com/news?type=Blog&amp;Category=Security then filter results to return all Article pages where type=Blog and Category=Security


We tried adding a contextual filter with the following settings only but it did not work.
Views Exposed filters already work this way, no need for any Contextual filters. 

In the settings for each Exposed filter there is an option to type in Filter identifier. That is the text that will be used for that field in the query. 

In your case set the Filter identifier of the Category to Category and of Type field to type. 



If you configure the Exposed filter Selection type settings for those two filters to Dropdown then you'll have to use term IDs in the link to make the filter work (I'm assuming your Security term has ID 6): 

www.mysite.com/news?Category=6

Use Autocomplete to get term names in query

But if you set the Exposed filter Selection type settings to Autocomplete you will be able to use term names, which is what you want. 

www.mysite.com/news?Category=Security 

or 

www.mysite.com/news?Category=Security+(6) 

Drupal 8 adds the term ID next to the term name when choosing from the autocomplete suggestion list, but that part isn't necessary. You can construct the link with Category name only and it will work. If the Category name has spaces in it, replace them with + in query. 

If you have more than one Exposed filter they get combined, for all types: 

www.mysite.com/news?Category=Chemistry

or 

www.mysite.com/news?Category=Chemistry&amp;type=

and for some specific type in addition to Category: 

www.mysite.com/news?Category=Chemistry&amp;type=Blog

or change order: 

www.mysite.com/news?type=Blog&amp;Category=Chemistry