Forums › Forums › Search & Filter Pro › Dynamically associating custom post type results to another custom post type
Tagged: custom post type
- This topic has 3 replies, 2 voices, and was last updated 8 years, 4 months ago by
Trevor.
-
Anonymous(Private) November 9, 2017 at 4:17 am #140859
Hi,
I have two custom posts types: Auction and Lot
In my ‘auction.php’ archive template, I’m trying to search all lots for the current auction.
My problem is simple, I need to tell the search to filter lots based on the Auction ID.
I can manually add the Auction ID as a Post Meta conditional for a single search form but that’s not quite good enough, I want to be able to add the Auction ID to the search form dynamically.
Can you explain some possible ways to achieve this?
Thank you!
Trevor(Private) November 9, 2017 at 12:07 pm #140914IF I understand you correctly, what you want to do is use the form system to filter results without using a user form. I do this on many sites that I have, but not quite the way you want I suspect. Are you wanting to have an archive page, where the Auctions are listed down the page, and then in each auction section you have a Lots archive run, but filtered by Auction ID? In effect, running our filter (the same filter) once for every Auction, but each time with a different Auction ID.
I had been building a site myself with this same type of structure, but if I made a sub-section for that loop inside each archive post, I had to make a URL with the condition added using PHP to construct the URL, and then load that in an iframe. The results were wholly unacceptable. It placed a huge load on the server and made page load a LOT slower.
Did I understand what you wanted correctly? If so, why not list the Lots in order (assuming any one Lot only appears in one auction), sorted by Auction ID and Lot ID, and use PHP to insert the Auction details every time the Auction ID changes?
Anonymous(Private) November 14, 2017 at 3:26 pm #141872Hi Trevor,
Thanks for your quick response and sorry for my slow one.
Are you wanting to have an archive page, where the Auctions are listed down the page, and then in each auction section you have a Lots archive run, but filtered by Auction ID? In effect, running our filter (the same filter) once for every Auction, but each time with a different Auction ID.
Essentially, yes but I’m not sure what you mean when you say “running our filter (the same filter) once for every Auction” since the filters should only be applied in the context of a single Auction, the filter should run once for one Auction.
Each Auction has multiple Lots on a page, 50 to be precise, the results are paginated because most Auctions have at least 400 Lots, some have more than 500. There are currently 20 Auctions on the site, so on average, there are around 10000 posts. Quick aside: Can this plugin handle that amount of data? I’m finding it very slow at the moment. Perhaps there are some performance tweaks you can recommend?
At the moment, I’m using a Post Meta filter to include the Auction ID on the Search/Filter form. Then, using Javascript, I insert the Auction ID into both the Min and Max input values so that when the User applies a search/filter, the Auction ID is passed along with the search parameters.
It’s hacky and I’m not fond of doing it this way but I needed to make some progress and it works 75% of the time.
I’d appreciate any additional help or advice.
Thanks for your time!
-
AuthorPosts