1

So I have 3 Custom Posts created with the Types plugin (the plugin should be irrelevant, anyway): 'Hotels', 'Rooms' and 'Webcams'. These last two are hierarchical, with 'Hotels' as their parent, set through the Types UI. Every post type has its own single-cpt.php template.

What I'm trying to achieve, let's say as an example that this is the post for the Grand Hotel:

  • Everything is shown on a page with tabs. When the visitor clicks one tab, that active tab shows the template for that Custom Post. So, for our Grand Hotel cpt:

  • First Tab shows single-hotel.php with its content. The url would be mysite.com/hotels/grand-hotel. This is the easy part, as the site is mainly focused on exploring hotels.

  • The second Tab shows the webcam for that hotel, using the template single-webcam.php template and the url mysite.com/webcams/grandhotel. The url part is what comes as default, so no problem with that.
  • The third, 4th and 5th Tabs show each one a different type of room for the Grand Hotel, using single-room.php template for each of the tabs 3, 4 and 5 and url's that should be mysite.com/hotels/grand-hotel/double-room, mysite.com/hotels/grand-hotel/another-room and, say mysite.com/grand-hotel/yet-another-room-type.

Now, for those last url's, I think I should work some kind of rewrite rule (maybe and endpoint?) to achieve that setup mysite.com/hotels/current-hotel/current-room-type. I would appreciate if someone could give me a hint of what would be the best approach.

But the biggest problem I'm facing is this: if I'm showing the single-hotel.php template with all the Tabs (being the first as the active one), what query should I put for the other tabs so the user being in the Grand Hotel can click any tab and go directly to the webcam or any room type for that same hotel?

I guess I could use some plugin like Posts 2 Posts or Types + Views premium add-on to establish relationships between all cpt's and specific cpt's with each other at will, but my question is more about wether this can or cannot be done in the templates themselves (or some arrangement in functions.php).

Thanks very much in advance.

Note: I'm developing my site on the Genesis Framework with a customized Sample Theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.