0

I have two custom post types.

  1. Destinations - destination custom post type has their posts and they are organized in hierarchical mode example:

    • Malaga
      • Food
      • Gallery
      • Rooms
    • Marbella
      • Food
      • Gallery
      • Rooms

Each of the destination post it was programmed to look as a page. Inside Rooms post (page) I can select other different custom post types from "Room" custom post type to be visible inside a Room page.

  1. Room - custom post type, have their details, price, description etc. Now when I am opening one of the destination page and then I click on Room it will open my room page. URL will be something like: "/rooms/room-name".

Now in room page I have all the room custom post types that I have selected.

Now my problem is that when I click on the rooms they will redirect me to custom post type URL example: "/room/room-name".

My question is how can I change the custom post type url, so when I click on room custom post type to not change the actual URL but just to add room title in URL example to be like:

"/malaga/rooms/room-name"

My problem is that destionation part is dynamic and I don't know how to do that ?

What changes do I need to do to be able to use custom post types in this way ?

  • Is the current setup of CPTs set in stone? You could set rooms as CPT and use destination as a custom taxonomy. This way a permalink like you wish would be much easier to get with the default permalink structure in WordPress – kero Nov 29 '18 at 12:55
  • The website it was programmed to have the destinations and rooms as a separate post types and I cannot change that. I need to do something with url rewriting but I am not totally sure because It is my first time that I have encounter this kind of problem. – Fakultet Nov 29 '18 at 12:59
  • Is it okay to rewrite everything in /X/rooms/room-name to the specific room? If not, how do we know malaga is a valid value and marbella is not? Does every room have a different name/slug? – kero Nov 29 '18 at 13:02
  • One room can be selected in multiple destinations. Each destionation has different slug and name /marbella or malaga. Each of the destinations has their own rooms page /marbella/rooms or /mallaga/rooms. In each of the rooms we have "room" custom post type posts selected and when users click on them it should be: /marbella/rooms/room-1 or /malaga/rooms/room-1. – Fakultet Nov 29 '18 at 13:05

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.