Custom Query for Multiple Tags and Custom Field
-
I am working on a real estate blog. Each post has a custom field called Maximum Guests, which is assigned a value between 1-20. The number of guests is also included in each post content and post excerpt in a standard format. So, either the custom field or the content or excerpt could be used to find this data. Each post is tagged with its amenities (i.e. Deck, Fireplace, Pets Allowed, Ocean View, etc).
When a site visitor searches, they can choose the total number of guests and types of amenities they are looking for (see https://estesparkrentals.allyourssolutions.com for example). I need a query that will pull posts with:
Number of guests (if visitor inputs 4, the query needs to display posts that specify 4,5,6,7…20 guests)
AND
Multiple amenities selectedFor instance, a visitor wants a property for 6 people that has a deck and fireplace… how can I make this work?
query_posts(tag=deck+fireplace);
works to effectively pull the desired amenities. Then I tried to use
$pos = strpos($excerpt, $findme);
in conjunction with get_the_excerpt() to scan the excerpt for the max number of guests. However, if it’s given 6, it ONLY pulls posts with Maximum Guests 6, not 6,7,8,9,10,11…20.Any ideas? Thank you for your time!
- The topic ‘Custom Query for Multiple Tags and Custom Field’ is closed to new replies.