How to allow user to perform search by more than one tag

Firstly, stop repurposing categories and tags, instead use custom taxonomies. This will give you:

  • archives and listings
  • URLs to view each taxonomy
  • User interfaces that match the names

I would personally have chosen a physician custom post type with specialty and location taxonomies. However I am assuming this is a way of filtering down posts so working off of this assumption, register these taxonomies:

  • location
  • specialty
  • physician

Next, throw your javascript away, and implement your interface as a form.

<form action="" method="GET">

With 3 select inputs with these names:

  • location
  • specialty
  • physician

The options in these select inputs will have values matching the slugs of each term.

For additional parameters such as order, put them in an input of type hidden.

Finally add a submit button and label it ‘search’. You should now have a non-js version of what you wanted.

You should also have these archives:

  • example.com/location/example
  • example.com/specialty/example
  • example.com/physician/example

And these templates available to you:

  • taxonomy-location.php
  • taxonomy.php
  • archive.php

etc for each taxonomy, refer to the template hierarchy diagram when deciding which one you wish to implement.

Leave a Comment