1

I'm looking to create some functionality on my custom theme I'm not sure if I need to research nested CPT or CPT with a page parent.

So my site will have two pages Cars & Bikes Each car & bike can be bought and sold at different locations there maybe more or less locations in the future so locations in my mind will be a CPT. The pages will have different information on depending on if the parent is a bike or car.

Slug Structure;

domain.com/car/london

domain.com/bike/london

What would be the best approach to setup this sort of link structure? Currently cars & bikes are pages. I can create a custom post type for locations and use categories as a taxonomy to tag them to specific categories. This will resolve any issues with page development identifying which page is page but won't give me the urls I'm after.

1 Answer 1

0

How necessary is it to keep that URL structure? I ask because I think it would be more confusing to site visitors as you have in your example, which uses singular rather than plural.

Putting myself in the mindset of a visitor to your site, I imagine that what I'm there to find is either a car or a bike, so it makes sense that that would be your CPT, not the location, which is an attribute of the car or bike. Even if I were to begin my search by looking in London, I'm still seeking a car or bike.

Yet your URL, domain.com/car/london assumes only 1 car - whereas I imagine I'd like to see a list of them first, before selecting one. So it makes more sense to start at domain.com/cars/ then click a link for my preferred location "London" and see what is available at domain.com/cars/london.

This means creating a CPT for Cars (singular = car) and Bikes (singular = bike) with a custom taxonomy of Location that applies to both (when setting up the taxonomy use 'taxonomies' => array( 'bike','car' ),).

You can then have your Page(s) ("Cars" and "Bikes" which give you the URLs of domains.com/cars/ and domains.com/bikes) and either display a list of all or have visitors begin by selecting a location from your list of location taxonomies). If your locations are close so that visitors might select from several, consider using a filtering plugin like Search&Filter or one of many others. That way folks can select multiple locations and still see results on one page.

If keeping your URLs the way you have them now is critical, post back and I or others can probably find some creative workaround for you, although IMHO I think it's best to work within what WordPress expects according to it's Template Hierarchy system....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.