I have states and cities. I also have listings. I have listings that belong to one city and listings that belong to multiple cities.
I want to display the single-city listings only on THAT particular city. I want to display listings that belong to multiple cities ONLY in those cities they belong to.
Let's say "Listing A" belongs only to Dallas, Texas and "Listing B" belongs to Dallas, Texas and a number of cities surrounding Dallas.
I want "Listing A" to only show up in Dallas and "Listing B" to show up in Dallas and (only) the other cities it belongs to (so neither should show up in Birmingham, Alabama).
I want to do the same thing for listings that belong to multiple states.
I've read the documentation, but nothing I've seen really matches what I want to do (so it's confusing). If you give me some privacy on the next post, I'll post the URL and my credentials.
PS: I also created CPT "Multiple City Area" as an intermediary post type. No, I don't know if that was correct or not. Like I said, I was confused.
In your case, bands is your listings.
(band can be in one or many events same your listings can be in one or many cities)
Events are your cities, and appearances will be your intermediary post "Multiple City Area".
Be sure you set "Multiple City Area" as child of cities and listings.
For make a new connection, create a new 'Multiple City Area' post and select in the bottom of the page the correct listing and city.
You can create as many "connection" (post) as you need
For display them, you should'nt have problem by folowing the documentation.
create view that loads all "Multiple City Area" from city
in view loop, display the parent listing of "Multiple City Area".
@ed: If solution provided by 'Christophe Lopez' doesn't help (which I think you should give a try to), please find the private area enabled for your next reply.
I have just observed your setup in your website. I tried replicating the same scenario on my local host and found that the solution prescribed by Christophe is a good-go.
I will copy the words below:
"...Be sure you set "Multiple City Area" as child of cities and listings.
For make a new connection, create a new 'Multiple City Area' post and select in the bottom of the page the correct listing and city.
You can create as many "connection" (post) as you need
For display them, you should'nt have problem by folowing the documentation.
create view that loads all "Multiple City Area" from city
in view loop, display the parent listing of "Multiple City Area"..."
And your question "Are you certain that "Multiple City Area" should be a child of cities and listings and not the other way around?"
Yes, that's correct, that "Multiple City Area" should be the child of Cities and Listings. Since, it's an intermediary object, changing it's relation will change the way it is connected. And of course the further way explained about creating a view to present the listings.
I hope this will help you fixing this very issue. Please let me know if I can help you with anything related, thanks.
I've been "messing" with this, on my own. I still can't wrap my head around the intermediary being a child of cities, because then each "Multiple City Area" can only have one parent city, when the object is for it to be attached to multiple cities (and possibly multiple listings).
I'll attempt this solution, later this morning. I'll let you know how it goes.
Yeah, that didn't work. I tried that, when it was first suggested. Having Multiple City Areas as children of Cities and Listings offers me no way to add multiple Cities to a Multiple City Area and adding more than one Multiple City Area to a Listing just doesn't even make sense (to me).
Maybe I need more help with the concept, than with the coding.
Alright, I will create a demo site from scratch and will implement this thing. I will share with you all the details. So you can compare and make adjustments.
Please allow me some time, I will get back to you soon, thanks.
Cities belong to States.
Cities also belong to Multiple City Areas.
Listings can belong to single Cities (mostly), multiple Cities (by attaching them to a single Multiple City Area or multiple Multiple City Areas), and/or States.
When viewing a single State, only listings that are "elevated" to State level will be shown.
When viewing a single City, listings belonging to that City will be shown, as well as listings that belong to a Multiple City Area which contains that City and listings that are "elevated" to State level (for that city's parent State).
Having multiple views in order to accomplish this is expected.
Again, you don't know how much I appreciate your help with this.
"Multiple City Area" is the intermediary post. It is used as a link between cities and listing.
"Multiple City Area" will be child of one listing and one city at a time.
But you can create as many "Multiple City Area" (link) as you need.
As you can see in img attached
if you want show all listing from city 1
In a city page, display all her multiple city area ( here n°1, n°2, n°3)
then display name of parent of multiple city area of type listing ( lst1, lst2, lst3)
if you want show all listing from city 2
In a city page, display all her multiple city area ( here n°4, n°5)
then display name of parent of multiple city area of type listing ( lst1, lst3)
i named the intermediary post Multiple City Area to follow your first post. But it can be less confusing to name whatever you want.