• I am trying to get a site set up that will show houses that are for sale by owner. I want the main site to have a single post for each house that is for sale, and I would like to use the custom fields to list certain details about each house (price, # of bedrooms, etc.).

    One of the most important functionalities will be having the ability so search through the posts to identify properties that fall within a certain price, number of bedrooms, etc.

    I am thinking of two completely different ways to go about this. One way is to search the custom fields and return results that match one or more of the parameters, which sounds difficult to say the least and does not allow for searching by ranges.

    The way I think I would like to go about it is to categorize the posts in multiple categories depending on the price, bedrooms, bathrooms, etc. So, I might have categories for price of $126k to $150k, $151k to $175k, etc. and bathroom categories of 2+, 3+, and so on. Thus, a property would be categorized based on price, bathrooms, bedrooms, and so on.

    My question is this: how can I search by category so the search returns only properties that belong to the multiple categories that are indicated? In other words, only posts that match ALL of the indicated categories should be returned rather than those that match ANY of the categories.

    I’m also open to other ways of going about this, but the categories thing seemed easiest to me.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter wittmania

    (@wittmania)

    Anybody?

    TimeMachine

    (@timemachine)

    The easiest way to do this in 2.3 or later is probably with tags. Categories are pretty limited. I’m not sure if it is due to bugs or design.

    For example:

    cat=1,2

    Will show everything from category 1 and 2 (Union).

    cat=1+2

    Fails.

    cat=1&tag=2-bedroom

    Fails.

    tag=2-bedroom,1-bathroom

    Works. Shows everything tagged 2-bedroom or 1-bathroom (Union).

    tag=2-bedroom+1-bathroom

    Works. Shows everything tagged with both 2-bedroom and 1-bathroom (intersection).

    You will have to do some coding but it will be pretty easy to create a form where the user can select check boxes to create a tag intersection query. You can do it all in php/html.

    I’m finding that cat=1,2 when querying index.php (i.e. index.php?cat=1,2) is only showing 10 posts from both categories, rather than all of them.

    /category/categoryname/ is doing the same. This is in 2.3.1.

    Wasn’t a problem in 2.0.1

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show posts from multiple categories’ is closed to new replies.