url rewriting - WordPress custom post type url change

admin2025-06-06  2

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 ?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749141861a316720.html

最新回复(0)