WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a pretty complex wordpress-site for travelling. There's an "archive-hotels.php", a template for the custom-post-type "Hotels". Inside the CPT is a taxonomy called "City", so we can do this: domain.com/hotels/city. Works perfectly. Now there's a filter on the site, which should filter the shown posts by stuff that the author has added over custom fields (Advanced Custom Fields Plugin) like "Features" or "Price Range".

Now I'm not sure how to filter that query. With PHP? jQuery (there shouldnt be too much posts in hotels/city/)? or Ajax to work that dataload, which will be after years of publishing?

Domain www.business-travelling.de/hotels/hamburg

share|improve this question
So when I search for .../hotels/hamburg?features=sea-face, the result should contain only the hotels in Hamburg which face the sea? – Rutwick Gangurde Apr 18 '12 at 9:38

The permalink structure you've described above e.g..../hotels/hamburg/features/sea-face isn't really something that could be achieved by using custom fields. You would be better off creating a new taxonomy called 'features' and populating it with terms like 'sea-facing' and any others.

In order to do queries for multiple taxonomies I would recommend the excellent Query Multiple Taxonomies plugin by Scribu. This plugin will let your users build searches that span across more than one taxonomy e.g. city AND feature.

You could either use the filter widget that comes with the plugin or build your own if that doesn't quite cut it. Think in the long run this will prove simpler than messing around with more complex ajax requests or complex wordpress queries looking for combinations of custom fields.

share|improve this answer
This looks pretty nice! Thank you! I don't need a fancy and pretty domain for this! I just want to filter the current query by some custom-field-values. Just like "I just want the user to visit hotels/berlin, click on a few arguments "Whirlpool, WiFi and Breakfast", press "Filter" and a filtered list of posts appear. If this works without Ajax and jQuery, it would be perfect too!" – juliusk Apr 18 '12 at 9:56
To be honest using a custom taxonomy for the features will not only be quicker and easier for you to implement (using the above plugin for filtering) but it will be easier for your client/you to administer in the wordpress backend - e.g. they just have to tick a few boxes in a custom taxonomy panel as opposed to adding in any custom fields. – FourStacks Apr 18 '12 at 10:01
Ok I get it. I will shoot for taxonomies. Important is: The new query has to include the current taxonomy, you're in, so you don't get hotels from other towns. – juliusk Apr 18 '12 at 10:06
Yep, it can handle that no problem. Just bear in mind that you don't have to stick to using the widget that comes with the plugin for filtering - you can build your own if understand how the multiple queries are built. – FourStacks Apr 18 '12 at 10:11
Yeah Ive implemented it. Awesome to work with. My one last problem: I had to rewrite my taxonomy-urls like this: /custom-post-type/taxonomy/. So your domains with "?taxonomy=XY" doesnt work :( – juliusk Apr 18 '12 at 10:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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