I'm looking for a way to query listings in PHP using Sabai Directory plugin. In my code, I extract the keywords from
$_SERVER['REQUEST_URI'] and then intend to use them to find matching listings. Now, the problem is I need a way to assign those keywords to my listings in the first place. I tried 2 approaches:
Categories. It seems that Sabai does not support core WP categories (does it?), but has its own version. So if you create a Category, Sabai creates a page with a permalink for it. However, my categories are very trivial, they just have a label and a value with no content or no media; I don't want users to see category pages (e.g.
/directory/categories/chocolate), it makes no sense.
- Is there a way NOT to create a separate page for each category?
- How do you query listings by multiple categories? Would this work:
[sabai-directory category="chocolate,arizona,phoenix"], with category separated by comma?
Custom fields. I couldn't figure out categories by myself, so I created custom fields to simulate core WP categories. But the problem is I can't find a way to query listings by these custom fields. So if I need
field_statefield to be set to
massachusetts, how do I limit my listings to either of those values?
- Is there a way to specify custom fields in shortcodes?
- Is there an API in Sabai that I can use to query listings directly? What would the post type be? What would the query look like? (There is no info on this in the docs)
On the same topic, once you query the listings, how do you display the contents for a single listing? I've tried
[sabai-directory-listing id="?"] shortcode, but I don't understand where you get the
$post->id doesn't work.
Please let me know if you have any info