0

I have a custom post types called Destinatiosn. These post on click opens as pages and they are organised hierarchically. Example:

  • Malaga

    • Food
    • Gallery
    • Rooms
  • Marbella

    • Food
    • Gallery
    • Rooms

Now in Rooms page, I am selecting to use other custom post types called "Room". In this page I will show selected custom post types. But my problem is that when I click on these custom post types URL is changing. I just want to add on existing url only the name of the room.

Example, I am in this page:

/marbella/rooms

On room custom post type click, I want room to be:

/marbella/rooms/room-name

But when I click Url changed to:

/room/room-name

function add_page_rewrite_rules(){ $url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH), '/'); $wp_rewrite->add_permastruct( 'room', $url_path . '/%room%', false ); }

But if I change url to something else working, when I am using example /malaga or /marbella it is not working and I don't know why ?

How can I resolve my problem ?

My question here is a unique because I have added a sample of code and I do not know why url:

$wp_rewrite->add_permastruct( 'room', $url_path . '/%room%', false );

is not working but when I change to some url which does not exist works.

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.