How are vendors and listings connected?

I’m trying to make a custom query for a vendor template, but I’m unsure how I can retrieve the listings for a specific vendor. I don’t see anywhere in the meta data that indicates the listings for the vendor, or the vendor on the listings. Any suggestions?

Vendor profiles are implemented as a custom post type “hp_vendor”, listings as a “hp_listing” post type, and vendor ID is set in the “post_parent” field for listings. The easiest way to query listings is using the HivePress models, for example:

\HivePress\Models\Listing::query()->filter( [ 'vendor__in' => [ 1, 2, 3 ] ] )->get();

Then you can use the queried listing objects to get field values this way:

$listing->get_fieldnamehere();

So you don’t have to remember whether it’s a meta or taxonomy field. We’re also working on the developer docs that should be released within a few days.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.