$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>url rewriting - Rewrite url for custom post type with specific url|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

url rewriting - Rewrite url for custom post type with specific url

matteradmin9PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far