0

I am building a theme for a local roofing company and we need to implement a solution for users to be able to search through custom posts and find what they're looking for based on custom field values.

For example, a user should be able to select that they are looking for all posts that match:

  • roofColor = green
  • roofType = shingles
  • roofCity = chicago
  • etc..

There will be hundreds of projects (custom post entries) to search through. I'm interested in best practices here. Is it okay to be using custom fields for my custom posts in this example and to search for posts that have the matching custom field values? I have heard that the way wordpress stores values like this in the db would make it inefficient or slow, so I'm wondering if it would be better to build my own database to handle the special values for each roofing project?

Thank you for your time and insight, it's greatly appreciated!

1 Answer 1

0

This sounds like the perfect use case for Custom Taxonomies.

And unless you plan to customize the admin backend, the Codepress Admin Columns plugin could be useful for filtering the posts using those new taxonomies.

Edit (2014.01.23):

Yes, you could build a "search form" where you would list the available taxonomies.

The get_categories() function will be useful to retrieve all the terms of a taxonomy, using the "taxonomy" parameter. Refer to the codex.

With that method, you could produce a dropdown list for each taxonomy.

The selection of that dropdown could generate a URL that includes the necessary parameters for the query: example.com/?roofcolor=green,red&roofcity=chicago+new-york ...

This would result in a page that displays the filtered content.

It seems to me that this is a pretty simple method of achieving what you want.

Here are two articles with more information about how to write complex taxonomy queries:

1
  • So with this method I would be able to set up a "Search" module where visitors could select all specific Taxonomies that would apply to the kind of post their looking for? In other words, selecting posts that belong to a specific set of taxonomies? Commented Jan 22, 2014 at 18:15

Your Answer

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

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