This is a one to many relationship where there are multiple properties to a park.
I have my archive page which shows all parks, but now I would like to create another search page (view) that shows only parks that have properies assigned to them.
Yes, you'll replace the following items in the code snippet to match your website:
- '12345': with the actual ID of your view
- 'property': with the actual slug of your property post type
- 'park-property': with the actual slug of your relationship between the park and the property post type
So after testing thoroughly and nearly writing a long ass post here about how it isn't working the way I wanted, I sat and read your code. Which is great btw!
So what I noticed was it was working correctly, however the opposite way to what I wanted, so I changed the 'parent' and 'child' around then changed the slug from properties to park and viola! it works!
So what I have come to realise is that I cannot just show the parks that have 'any' properties linked.
I have a taxonomy which allows people to mark the properties as;
For Sale, Sold, Draft/Save for later or Under Offer.
Anything Sold has been removed from any listings on the website.
However, using this formula works, but it still shows the parks that have attached Sold items.
Is there a way I can also negate 'Sold' items from the search even though they're attached via a relationship?
For example;
You can see each park has 1 Private Sale(s), but Rownhams Park does not.
This is because the one attached to Rownhams Park has been marked as 'Sold', so shouldn't technically show on this list.
Any help with this would be greatly appreciated, I am soo very nearly there with it!
Thanks
Steve
New threads created by Waqar and linked to this one are listed below: